Maths is smART |
Maths is smart, maths is art.
|
Here is the last of the star fractals followed by the Matlab code. If you have any questions about the code please ask.






function A = starsfractal(itterations, N, d, x_center, y_center, radius, direction, null_pt)
hold on
start = (N-2)*pi/(2*N) + mod(N,2)*direction*pi/N;
t = linspace(start,start+2*pi,N+1);
t(N+1)=[];
x = radius*cos(t);
y = radius*sin(t);
for i=1:N
X = [];
Y = [];
for j=1:N+1
X = [X x(mod(i+j*d,N)+1)];
Y = [Y y(mod(i+j*d,N)+1)];
end
set(gca, ‘ColorOrder’, [0.2 0.4 0.3]);
plot(X + x_center,Y + y_center)
end
if itterations ~= 1
star_pos = 1:N;
if null_pt ~= 0
star_pos(null_pt) = [];
end
for i=star_pos
j = mod(i+floor(N/2)+direction*mod(N,2),N);
if j == 0
j = j+N;
end
starsfractal(itterations - 1, N,d,4*x(i)/3 + x_center, 4*y(i)/3 + y_center, radius/3, mod(direction + 1,2),j);
end
end
There are so many inputs because of the recursive construction of the fractals. The only things you need to worry about is itterations, N and d. You should set the other values as default:
How cool is this star fractal :)
It is quite hard to define what a fractal is… Here is what wikipedia says:
A fractal has been defined as “a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole,”a property called self-similarity.
As well as fractals appearing in nature (which I think is quite amazing), there are many famous “man-made” fractals which are created by some given algorithm. One example of these is the star fractal. Basically you draw some star polygon and at each point draw the same star polygon ‘the other way up’ of some smaller propotion…. continue until you can’t see your stars turn to dots :).
I didn’t want to make the picture myself so I decided to get matlab to do it for me, I have used the simple pentagram as my star-polygon but I have coded the program so I can easily use any star-polygon:




I will post some more star-fractals tomorrow as well as the code if you would like it. Please enjoy :)