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:
Everyone was too smart for me and guessed the right family of distributions, that is the beta distribution. How about these? If you don’t know just enjoy the picture :)
I hope you like this picture, this picture was wholey created using matlab! Maybe not the most productive thing to use matlab for but it was fun and I like the end result:

If you would like to see more pictures like this just give me a scene or scenario and I will have a go. Thanks! If any of you wanted the code here it is:
%sky
clf
x = [-3:0.1:13];
hold on
for i=1:0.2:13
set(gca, ‘ColorOrder’, [rand*50 rand*55+200 rand*100]./255);
set(gca, ‘ColorOrder’, [rand*50 rand*100 rand*55+200]./255);
plot(x,i);
end
%sun
nopoints = 20;
x = linspace(-1.88,1.88,nopoints);
dt = 0.05;
n = 1/dt;
theta = 2*pi*dt;
A = [cos(theta) -sin(theta); sin(theta) cos(theta)];
y = cos(x);
for i=1:n
for j=1:nopoints
v = [x(j);y(j)];
vnew = A*v;
x(j) = vnew(1);
y(j) = vnew(2);
end
set(gca, ‘ColorOrder’, [rand*50+205 rand*50+205 rand*50]./255);
plot(x+10,y+10)
end
%tree trunk
x1 = [-1:0.01:-0.2];
x2 = [0.2:0.01:1];
set(gca, ‘ColorOrder’, [139 69 19]./255);
for i=0:0.1:0.4
plot(x1+i,0.2./(x1.^2))
end
for i=0:0.1:0.4
plot(x2-i,0.2./(x2.^2))
end
%tree top
t = linspace(0,16*pi,1000);
for i = 0.5:0.1:2
x = (2*cos(t)+i*cos(8*t))./2;
y = (sin(t)+i*sin(8*t))./2+5;
set(gca, ‘ColorOrder’, [rand*100 rand*50+205 rand*50]./255);
plot(x,y)
end
%grass
x = [-3:0.1:13];
for i=-4:0.05:1
set(gca, ‘ColorOrder’, [rand*50 rand*55+200 rand*100]./255);
plot(x,i);
end
%rainbow
n = 140;
ColourMatrix = zeros(n+2,3);
for i=1:n/7
ColourMatrix(i,:) = [255 153*7*i/n 0]./255;
ColourMatrix(i+n/7,:) = [255 (255-153)*7*i/n+153 0]./255;
ColourMatrix(i+2*n/7,:) = [-255*7*i/n+255 255 0]./255;
ColourMatrix(i+3*n/7,:) = [-255*7*i/n+255 -255*7*i/n+255 255*7*i/n]./255;
ColourMatrix(i+4*n/7,:) = [0 65*7*i/n (106-255)*7*i/n+255]./255;
ColourMatrix(i+5*n/7,:) = [143*7*i/n -65*7*i/n+65 (255-106)*7*i/n+106]./255;
ColourMatrix(i+6*n/7,:) = [(255-143)*7*i/n+143 255*i/n 255]./255;
end
t = linspace(0,pi,n);
for r=linspace(5,6,n)
x = (11-r)/2*cos(t)+9;
y = (11-r)/2*sin(t)+0.8;
set(gca, ‘ColorOrder’,ColourMatrix(floor((r-5)*n+1),:));
plot(x,y)
end
hold off
Magic Eye
I got alot of good response from the picture I created on Gnuplot I decided to try and make another one. Again this was a simple code produced with C and copied into Gnuplot terminal, it kind of looks like one of those magic eye pictures don’t you think? Perhaps if you stare at it long enough it will spell something out to you… If so let me know :)
Double Rainbow
Double rainbow all the way across the sky!
Rainbow
This was actually quite a challenge to do, I had to create a colour matrix that created a gradual change to each colour in the rainbow. Here is the code:
clf
hold on
n = 140;
ColourMatrix = zeros(n+2,3);
for i=1:n/7
ColourMatrix(i,:) = [255 153*7*i/n 0]./255;
ColourMatrix(i+n/7,:) = [255 (255-153)*7*i/n+153 0]./255;
ColourMatrix(i+2*n/7,:) = [-255*7*i/n+255 255 0]./255;
ColourMatrix(i+3*n/7,:) = [-255*7*i/n+255 -255*7*i/n+255 255*7*i/n]./255;
ColourMatrix(i+4*n/7,:) = [0 65*7*i/n (106-255)*7*i/n+255]./255;
ColourMatrix(i+5*n/7,:) = [143*7*i/n -65*7*i/n+65 (255-106)*7*i/n+106]./255;
ColourMatrix(i+6*n/7,:) = [(255-143)*7*i/n+143 255*i/n 255]./255;
end
t = linspace(0,pi,n);
for r=linspace(5,6,n)
x = (11-r)*cos(t);
y = (11-r)*sin(t);
set(gca, ‘ColorOrder’, ColourMatrix(floor((r-5)*n+1),:));
plot(x,y)
end
hold off
I hope I explain well enough, if you ever want to ask me something you can email me on mathsissmart@gmail.com
I generated Brownian motion in one dimension and changed the colour matrix to obtain different textures. Here are some of the results:




Hey guys! I would like to thank you again for all the support you have showed me. I know this is still a very small blog but I am proud of the interest that I have gotten so far. I have just been posted on the website http://coolmathguy.com/ which is a big deal for me as I have been visiting this website regularly for a while now. You can find the post at the following link: http://coolmathguy.com/little-math-art-tumblr
Now I just wanted to show you one more picture I created using the code from “Around and around” which I posted yesterday. Am sorry for the it being too repeatitive but I promise something more interesting coming soon! Thanks again :)

Some more pictures using the code that I posted yesterday.


And the following one which is my favourite:

Thank you all for the support and encouragement :)
About a week ago I blogged about randomness and one of the pictures I posted looked like this:

This was created using the following code:
nopoints = 20;
x = linspace(-1,1,nopoints);
dt = 0.005;
n = 1/dt;
theta = 2*pi*dt;
A = [cos(theta) -sin(theta); sin(theta) cos(theta)];
y = x;
clf
hold on
for i=1:n
for j=1:nopoints
v = [x(j);y(j)];
vnew = A*v;
x(j) = vnew(1);
y(j) = vnew(2);
end
set(gca, ‘ColorOrder’, rand(1,3));
plot(x+10,y+10)
end
hold off
Granted this is a bit complicated for the effected created but I wanted to change the 7th line to another function and just by that simple change create more interesting pictures. Well that is what I have done, and here are a few of the consequences:


I will post more tomorrow, including my favourite! For now, what function do you think I used for this picture:
