Saturday, March 18, 2006

It's a cliche, butter spreads nicely on 3D Mandelbrot


Thats right, you heard me. I am talking about almond-bread, not Benoît Mandelbrot, a French mathematician (wikipedia if you want to find out about him).

Anyway, yummy breakfast plans aside, I worked on doing some plotting of the Mandelbrot set fractal while eating a bagel with cream cheese (the American equivalent to the German mandelbrot and Nutella®).

this is a function f(x, y) which returns a value, which I treat as the height on a heightmap.

(YAY i figured out how to post code!! i will put some code in my earlier posts for those who are interested)

[code]

double mandelize(float x, float y, int max)
{

double x1, y1, xx, xmin, xmax, ymin, ymax = 0.0;

double xperc=x/(float(max));
double yperc=y/(float(max));

int looper = 0;

//this here determines where on the set the view is focused. Right now, this is a zoom on a //region of the set which produced the below renderings
xmin = -0.487f;
ymin = -0.629f;
xmax = -0.486f;
ymax = -0.630f;

x = xmin + xperc*(xmax-xmin);
y = ymin + yperc*(ymax-ymin);
x1=0;
y1=0;
xx=0;
looper = 0;

//this loop keeps track of how long it takes for the function to grow both x and y.
//whenever the distance from the coordinates to the origin becomes larger than 2,
//the loop exits. If this doesnt happen before the counter reaches 200, then the point
//is considered to be an element contained in the mandelbrot set at this resolution
while(looper < xx =" (x1" y1 =" 2" x1 =" xx;" xperc =" looper" val =" (xperc" style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://photos1.blogger.com/blogger/6686/2189/400/Mandelbrot3DZoom2.jpg" alt="" border="0">

The technique that i used to display the terrain is an iterative detailing technique. I start with a square (this represents the viewing area) which is made of 4 triangles. Then we test the shared vertexes and see if there is a large disparity between the values of nearby points. If the difference is great enough, we "break" the triangle in question in two. This is done everywhere where it is necessary up to a certain maximum depth which is a constant that represents the resolution of the rendering.

Without further discussion, here are some more renderings of a zoomed region of the mandelbrot set (in 3D).

2 Comments:

Anonymous Anonymous said...

Okay, do you realize how amazingly awesome those pictures would be if the colors on the triangles weren't completely insane? I'm glad you spent the time to adaptively break up the triangles, something that Namaste and I didn't do when we wrote this program, because ours looked like crap and this could potentially look incredible. Just give it better colors.

5:49 AM  
Blogger Max Rebuschatis said...

Sounds good. I appreciate the encouragement, Luke. I will work on changing the colors tonight. The idea that occurs to me right away is to color based on the height like a topographical terrain map. White=alpine, green=medium, blue=low etc.

I will post some pics.

5:01 PM  

Post a Comment

<< Home