Skip to content

Instantly share code, notes, and snippets.

@dmboyd
Created October 17, 2012 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmboyd/3903785 to your computer and use it in GitHub Desktop.
Save dmboyd/3903785 to your computer and use it in GitHub Desktop.
2000x2000 Gibney Fractal Attempt
## Author: dmboyd - Public Domain
## directly derived from descriptions given by http://www.gibney.de/does_anybody_know_this_fractal
xdimension=1000;
ydimension=xdimension;
scale=xdimension;
xoffset=xdimension/2;
yoffset=xoffset;
sensitivity=0.3;
gscale=50;
c=ones(xdimension,ydimension);
xvector=[];
yvector=[];
gdivc=[];
imagex=[];
#load up two vectors to 1..n
[x,y]=meshgrid(0:xdimension,0:ydimension);
x=x/scale;
y=y/scale;
xvector=x(:);
yvector=y(:);
c=complex(xvector,yvector);
g=complex(0:gscale,0:gscale);
#create complex numbers from the two vectors
n=length(c);
c(1)=0.01; #cant divide by zero;
#vectorised loop begin
cmul=1./c;
gdivc=cmul*g;
imagex=((((mod(real(gdivc),1)).*(mod(imag(gdivc),1)))-1).**2);
#end vectorised loop
#shape the vector to 2d
fractal=reshape(sum(imagex'),xdimension+1,ydimension+1);
# convert quadrants back into one big image
fractal=[rot90(fractal,2),flipud(fractal);fliplr(fractal),fractal];
image(fractal);
@dmboyd
Copy link
Author

dmboyd commented Oct 18, 2012

Could potentially change the code to restrict c to complex numbers a+bi where a>=b as it is symetric accross the diagonal axis. Would mean that you could fit twice the amount of complex numbers in memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment