View Full Version : 3D Mandelbrot Set

can you believe that this picture is a plot of a 3D mandelbrot set !!:

http://plus.maths.org/latestnews/sep-dec09/mandelbrot/mandel3d.jpg

look at those great images here( very big page with many links):

http://www.skytopia.com/project/fractal/mandelbulb.html

i hope i can find some complete algorithm to implement those 3d mandelbrot in thinbasic

look at the following image from a "3D Fractal Gallery" wich resembles a temple it is in the bottom of other page:

http://www.skytopia.com/project/fractal/mandelbrot.html

http://img204.imageshack.us/img204/5143/templeofshadow.jpg

all in all the site is magnificent, look at the projects tab ; many goodies.

another ref is an article "Pandora's 3D box" in the great free math magazine :

http://plus.maths.org/latestnews/sep-dec09/mandelbrot/index.html?nl=1

Beautiful stuff Zak, thanks.

Hi Zak,

You might want to look up quaternion Julia sets... those are really beautiful 3D projections of 4D fractals using quaternions (4D analogs of the complex plane).

I have some C/OpenGL/GLUT code that draws a point cloud quaternion Julia set, including a 3D Mandelbrot set from quaternions. It looks a bit different from the picture you posted, but interesting nonetheless. I would be happy to post the C code here as an attachment if you are interested? The skeleton of the program is similar to the FreeBasic OpenGL/GLUT parametric equation/trackball rotation program I posted in the Wayne City High gaming forum. The difference is in the math and plotting the quaternion point clouds (and the fact that the code is in C...).

A thinBasic port would be fantastic!

Cheers,

Stan

Hi Stan

yes of course, if i or other user can convert some C codes to thinbasic this will be fantastic. we will try.

thanks

Hi Zak,

I'm attaching a picture:

6950

As well as the FreeBasic program that created the picture. What you see above is a Quaternion Julia Set rendered as a display list. It was created by testing 100 million random points in a 4x4x4 box using quaternions in a fashion similar to the 2D Mandelbrot Set in my Python text. The above image has full trackball rotation using the mouse point (passive mode).

I translated the program from C to FreeBasic and noticed no degradation in either speed of calculation or in animation. The original C program was created from a skeleton (illiSkel.c) provided by my good friend Prof. George K. Francis (Mathematics) at the U of I. I provided the quaternion math, Mandelbrot, and half-set options in C and the entire translation to FreeBasic.

The exe file below has 25 million test points... so be patient while the calculations are being done :D

Cheers,

Stan

Hi Stan

the 3d graphics is great especially the 3D mandel , thanks for this, it is a pleasure for the eyes, it is good you have enabled choosing julia or mandelbrot (mand = 1 in your freebasic code) i have enjoyed more by the 3d mandel ,have you tried iter=5, incr = 5 the figure is like the temple above. i have downloaded freebasic and tried your examples, and indeed it is a speedy language.

i have translated your code to thinbasic, but as always there is obstacles. in never exit the calcit function if the loop is approximately more than 30000, so i tried manualy to choose :

glBegin(%GL_POINTS)

For foo = 0 To 30000

instead of

for foo = 0 to 1000000*incr

now even after that when going to function doRender() it stop in line:

glMultMatrixf (VarPtr(aff(1)))

error: Expected a parameter passed BYREF but found something else.

aff(1) is the first from array to aff(16).

so here is my buggy program.

as a reference to using :

TBGL_NewList

....

TBGL_EndList

look at my post about biomorphs there is a usage for lists:

http://www.thinbasic.com/community/showthread.php?10430-Biomorphs-a-Fractal-creatures

again thanks for enabling us to see some freebasic examples.

PS: be carefull if want to experiment with the more than :

For foo = 0 To 30000

and you want to exit by clicking "X", the thinbasic.exe will still swimming in the memory, the only way to end process: by ctrl-alt-del, it is a problem of all ms windows programs

correction:

there is an error in Dim foo As integer:

it must be : Dim foo As Long ,this is why the loop can't go too much.

but now if the loop is more than 100000 it stay too long.

add to that the second error as reported above

attached the second still buggy version with the loop :

For foo = 0 To 100000

i want to add that the aliases to GLdouble GLfloat ...etc are at the beginning of the file thinbasic_GL.inc

this is the last correction i will post, my brain is very loosy, i forgot things easily

the latest version seems works even too slow:

correction:

instead of : glMultMatrixf (VarPtr(aff(1)))

replace with:

rr = VarPtr(aff(1))

glMultMatrixf rr

doMain() is now within While TBGL_IsWindow

changed the loop to 1000000

now it is acceptable but still does not display but a dot not a figure.

Hi Zak,

I also saw a single dot running the program. I then commented out the:

rr = VarPtr(aff(1))

glMultMatrixf rr

statements and the next run I saw many dots in a pattern, but did not see anything recognizable and no rotation.

I think this is progress and its doable... I'm wondering if it would be better to use native TBGL rather than mixing in OpenGL? Just a thought.

Nice work!

Stan

Petr Schreiber

28-11-2010, 22:21

Hi Zak,

you made great progress on the translation. Some parts of original code seem quite redundant, if you look at the Aff array... it is just identity matrix. You get it when you call TBGL_ClearFrame already (this behavior can be disabled via params), so no need to struggle with it.

I attach code which shows the points, I added percentage counter to console title.

Petr

The aff matrix was designed to hold the rotation matrix... it starts out as the identity matrix, but then gets manipulated by various rotations and is then used to display the graphics object in a trackball orientation.

That was in the original OpenGL/GLUT program... in C. The concept was not developed by me, but by the wizards at the University of Illinois (George Francis, Stuart Levy, and others). The chaptrack function does the main matrix "stuff" and then prior to rendering, there are a couple of matrix commands to make everything work properly. I have translated the C code into Python, FreeBasic, and PowerBasic with success (although Python is slow!).

It was my hope to translate this trackball rotation to thinBasic, but so far I've had issues and I think it is because I (we) are mixing OpenGL with TBGL and the two are "fighting" with each other a bit (of course, I may be incorrect!).

The best solution would probably be to translate everything into native TBGL and thinBasic, but I don't have the skills yet.

Anyway... this is fun!

Stan

Thank you Petr for solving the problem, i begin to despair from showing at least the graphic dots. congratulation on the robots project and for returning home

best wishes

zak