Maths is smART |
Maths is smart, maths is art.
|
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 :)
I hope you enjoy the following pictures created in matlab. Although it seems these pictures are disordered they were created with only the functions sin,cos,exp and sqrt. No randomness was used!
A ball of string

Rhubarb Crumble

Pain Wheel

I like creating new shapes using some algorithm. I don’t think the following shapes have a name so please help me come up with one, alternatively if they already have a name let know.
I have created the following shapes using this algorithm, given an integer N:
Examples:
N = 25

N = 50

N = 100

N = 1000

Question: What are the angles created by two lines meeting at an end point?
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 :)
I have only recently started using Gnuplot (literally only for a few weeks) but combined with C it is a powerful way of creating nice images. I used this simple code in C:
#include <stdio.h>
int main()
{
int i;
printf(“plot [0:10][1:9] \”);
for(i = 0; i < 200 ; i++)
printf(“sin(x)+(%f) with filledcurve x2, \\n”, (double) i/20);
printf(“sin(x)+10 with filledcurve x2”);
return(0);
}
Then I copied the output into Gnuplot and got the following result:

Obviously very simple but I will try to master Gnuplot and post some really cool pictures!
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:



