File:Spiral of black and white squares 10 till repetition spiraling in.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Size of this preview: 600 × 600 pixels. Other resolutions: 240 × 240 pixels | 480 × 480 pixels | 1,000 × 1,000 pixels.
Original file (1,000 × 1,000 pixels, file size: 1.79 MB, MIME type: image/gif, looped, 50 frames, 1.0 s)
File information
Structured data
Captions
Summary[edit]
DescriptionSpiral of black and white squares 10 till repetition spiraling in.gif |
Deutsch: Sich wiederholende, schwarze und weiße Quadrate.
English: Self-similar, repeating black and white squares. |
Date | |
Source | Own work |
Author | Jahobr |
Other versions |
|
GIF development InfoField | |
Source code InfoField | MATLAB codefunction Spiral_of_black_and_white_squares()
% source code for drawing the animation
%
% 2017-04-26 Jahobr
fps = 50;
[pathstr,fname] = fileparts(which(mfilename)); % save files under the same name and at file location
figHandle = figure(15124455);
clf
axesHandle = axes;
hold(axesHandle,'on')
set(figHandle, 'Units','pixel');
set(figHandle, 'position',[1 1 1000 1000]); % set default
set(axesHandle,'position',[0 0 1 1]); % stetch axis bigger as figure, easy way to get rid of ticks [x y width hight]
set(figHandle,'GraphicsSmoothing','on') % requires at least version 2014b
L(1) = 1; % definition, length of first square
xyLim = [-L(1) L(1)]*0.99;
xlim(xyLim); ylim(xyLim); % set axis limits
axis equal; drawnow;
for nSquaresTillRep = [4 10] % ONLY EVEN NUMBERS! number of squares till the orientation repeats (90°)
alpha = pi/2/nSquaresTillRep;
% +--a1--+==----b1------+
% I / ----____ a1
% b1 / ----+
% I / 90° /I<-alpha
% I / / I
% I / / I
% I/ / b1
% +---___ / I
% a1 ----___ / I
% +----b1-------=+--a1--+
for index = 1:nSquaresTillRep+1
% L = a+b
% tan(alpha) = a/b; tan(alpha)*b = a
% 1 = tan(alpha)*b+b = b*(tan(alpha)+1)
b(index) = L(index)/(tan(alpha)+1);
a(index) = L(index)-b(index);
L(index+1) = sqrt(a(index)^2+b(index)^2); % side length of inner square
end
for currentCase = 1:2
switch currentCase
case 1 % zoom
nFrames = 200;
set(figHandle, 'position',[1 1 500 500]); %
method = 'zooming_in';
endVal = log( 1/L(nSquaresTillRep+1) );
scale = linspace(0,endVal,nFrames+1);
scale = exp(scale);
scale = scale(1:end-1); % cut of doubled frame
rotImage = linspace(0,-pi/2,nFrames+1);
rotImage = rotImage(1:end-1); % cut of doubled frame
case 2 % spiral
if nSquaresTillRep == 4
nFrames = 100;
set(figHandle, 'position',[1 1 700 700]); %
elseif nSquaresTillRep == 10
nFrames = 50;
set(figHandle, 'position',[1 1 1000 1000]); %
else
error('not defined')
end
method = 'spiraling_in';
endVal = log( 1/L(3) );
scale = linspace(0,endVal,nFrames+1);
scale = exp(scale);
scale = scale(1:end-1); % cut of doubled frame
rotImage = linspace(0,-2*alpha,nFrames+1);
rotImage = rotImage(1:end-1); % cut of doubled frame
end
sb = b(1); % scale square down one itteration (assuming a(1)+b(1)=1)
sa = a(1); % scale square down one itteration (assuming a(1)+b(1)=1)
for iFrame = 1:nFrames
cla(axesHandle) % fresh frame
col = [0 0 0]; % start black
curScale = scale(iFrame);
x = curScale*[-L(1) -L(1) L(1) L(1)]; % make base square bigger, to "zoom in"
y = curScale*[-L(1) L(1) L(1) -L(1)]; % make base square bigger, to "zoom in"
if currentCase == 2 % rotate base square
rotM = [cos(-rotImage(iFrame)) -sin(-rotImage(iFrame)); sin(-rotImage(iFrame)) cos(-rotImage(iFrame))];
vecTemp = rotM*[x; y];
x = vecTemp(1,:);
y = vecTemp(2,:);
end
while norm([x(1) y(1)]) > 0.5/900 % squares smaller than a pixel
patch([x x(1)],[y y(1)],col,'EdgeColor','none');
col = 1-col; % flip color
x = [sb*x(1)+sa*x(2) sb*x(2)+sa*x(3) sb*x(3)+sa*x(4) sb*x(4)+sa*x(1)]; % create next square
y = [sb*y(1)+sa*y(2) sb*y(2)+sa*y(3) sb*y(3)+sa*y(4) sb*y(4)+sa*y(1)]; % create next square
end
%% save animation
xlim(xyLim); ylim(xyLim); % set axis limits
drawnow % update figure window and execute pending callbacks
pause(0.01)
f = getframe(figHandle);
if iFrame== 1
map = gray(8); % 8 colors % create color map % or use : [im,map] = rgb2ind(f.cdata,4,'nodither'); %
im = rgb2ind(f.cdata,map,'nodither'); % create first image
im(1,1,1,nFrames) = 0; % allocate
if currentCase == 1
if ~isempty(which('plot2svg'))
plot2svg(fullfile(pathstr, [fname '_' num2str(nSquaresTillRep) '_till_repetition.svg']),figHandle) % by Juerg Schwizer, See http://www.zhinst.com/blogs/schwizer/
else
disp('plot2svg.m not available; see http://www.zhinst.com/blogs/schwizer/');
end
end
end
imtemp = rgb2ind(f.cdata,map,'nodither');
im(:,:,1,iFrame) = imtemp;
end
imwrite(im,map,fullfile(pathstr, [fname '_' num2str(nSquaresTillRep) '_till_repetition_' method '.gif']),'DelayTime',1/fps,'LoopCount',inf) % save gif
disp([fname '_' num2str(nSquaresTillRep) '_till_repetition_' method '.gif has ' num2str(numel(im)/10^6 ,4) ' Megapixels']) % Category:Animated GIF files exceeding the 50 MP limit
end
end
|
Licensing[edit]
I, the copyright holder of this work, hereby publish it under the following license:
This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 22:36, 12 September 2017 | 1,000 × 1,000 (1.79 MB) | Jahobr (talk | contribs) | GraphicsSmoothing with matlab version 2017a, 8 colores, more pixel | |
09:06, 26 April 2017 | 450 × 450 (562 KB) | Jahobr (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following 8 pages use this file:
- User:Jahobr/Files with MATLAB code
- User:Jahobr/Fractals
- User:Æo
- File:Spiral of black and white squares 10 till repetition.svg
- File:Spiral of black and white squares 10 till repetition zooming in.gif
- File:Spiral of black and white squares 4 till repetition.svg
- File:Spiral of black and white squares 4 till repetition spiraling in.gif
- File:Spiral of black and white squares 4 till repetition zooming in.gif
File usage on other wikis
The following other wikis use this file:
- Usage on de.wikibooks.org
- Mathematrix: Aufgabensammlung/ Bruchrechnungen und Vorrang
- Mathematrix: Aufgabensammlung/ Zahlenmengen
- Mathematrix: Aufgabensammlung/ Geometrie Beweise
- Mathematrix: Aufgabensammlung/ Binomische Formeln erkennen
- Mathematrix: Aufgabensammlung/ Mittelwerte Argumentationsaufgaben
- Mathematrix: Aufgabensammlung/ Textaufgaben Primfaktorzerlegung
- Mathematrix: Aufgabensammlung/ Bruchtermegleichungen
- Mathematrix: Aufgabensammlung/ Binomialverteilung
- Mathematrix: Aufgabensammlung/ Ableitung von Potenzfunktionen
- Mathematrix: AT BRP/ Theorie/ Reifeniveau 2
- Mathematrix: Aufgabensammlung/ Einheiten und physikalische Größen
- Mathematrix: Aufgabensammlung/ Anwendung der Normalverteilung bei gegebenen Erwartungswert und Standardabweichung
- Mathematrix: AT BRP/ Theorie nach Thema/ Lineare Gleichungssysteme
- Mathematrix: AT AHS/ Theorie nach Thema/ Geometrische Konstruktionen
- Mathematrix: AT AHS/ Theorie nach Thema/ Geometrie der Ebene
- Mathematrix: AT BRP/ Prüfungsbeispiele/ Normalverteilung
- Mathematrix: AT BRP/ Prüfungsbeispiele/ Mengenlehre
- Mathematrix/ Bilderverzeichnis
- Mathematrix: Aufgabensammlung/ Geometrische Aufgaben
- Mathematrix: Aufgabensammlung/ Trigonometrische Aufgaben
- Mathematrix: Aufgabensammlung/ ExponentialfunktionS
- Mathematrix: Aufgabensammlung/ Potenzen
- Mathematrix: AT HAK
- Mathematrix: Aufgabensammlung/ Wachstums- und Abnahmeprozesse
- Mathematrix: Aufgabensammlung/ Vorrang der Rechenarten
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Einheiten und Zahlendarstellung
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Exponentialfunktion
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Kurvendiskussion Umkehraufgaben
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Kurvendiskussion direkte Anwendung
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Integrieren
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Mittelwerte und Standardabweichung
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Prozentrechnung
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Boxplot
- Mathematrix: AT AHS/ Prüfungsbeispiele/ Binomialverteilung
- Usage on en.wikipedia.org
- Usage on en.wikibooks.org
- Usage on it.wikipedia.org