Mandelbrot fractal with the Prop
Rayman
Posts: 14,826
It's actually much simpler than I would have thought...
Here I generated the Mandelbrot fractal using SPIN.· It took ~3 hours, but this is because I did it all in SPIN (no assembly) and choose a rather high iteration limit of 255.· The resolution is 320x240.
It would be interesting and easy to zoom into any part of the fractal, but I haven't done that.
This could easily be ported to TV (using graphics.spin) with 4 color output or to VGA.· I think 4 colors is actually enough to get the gist of it...
Anyway, here's a photo of the result:
The real trick is generating colors from the result...· The result is the number of iterations until some·threshold is reached.· If the·threshold is reached fast, I've made it red, if the·threshold is never reached (because of the·255 cycle limit I've imposed), the·result is black.· Determining colors for in between iteration values is where it becomes more art than science...
Post Edited (Rayman) : 4/20/2009 12:17:34 AM GMT
Here I generated the Mandelbrot fractal using SPIN.· It took ~3 hours, but this is because I did it all in SPIN (no assembly) and choose a rather high iteration limit of 255.· The resolution is 320x240.
It would be interesting and easy to zoom into any part of the fractal, but I haven't done that.
This could easily be ported to TV (using graphics.spin) with 4 color output or to VGA.· I think 4 colors is actually enough to get the gist of it...
Anyway, here's a photo of the result:
The real trick is generating colors from the result...· The result is the number of iterations until some·threshold is reached.· If the·threshold is reached fast, I've made it red, if the·threshold is never reached (because of the·255 cycle limit I've imposed), the·result is black.· Determining colors for in between iteration values is where it becomes more art than science...
Post Edited (Rayman) : 4/20/2009 12:17:34 AM GMT
Comments
P.S. What is a fractal?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontrolled.
This is a very clever way of doing fractal generation.
What is the screen you have it connected to?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontrolled.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontrolled.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propalyzer: Propeller PC Logic Analyzer
http://forums.parallax.com/showthread.php?p=788230
can you do fractal in real-time at around 15frames a seconds.
Something like Linus demo.
This way you can zoom in fluently
·
Going from 1 frame in 3 hours to 15 fps would be a challenge!· But, I've done no optimizations at all...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontrolled.
Nice project. It's beautiful.
Let 8 COGs calculate in parallel. That's the easies you can do. Simply divide the picture in 8 pieces and let each COG calculate one part. Without other optimisations it would be done in ~20 minutes then.
2nd optimisation:
I think there is an algorithm which uses integer instead of float.
I'm not sure if the prop can do zooming in realtime, but it should be possible doin it in seconds instead of hours. And we currently don't know if the demo is really calculating the fractal in realtime because demos use tricks. My guess is that the image is calculated in a higher resolution during runtime of another part of the demo. Then it's zooming into the higher resoltion, but static picture.
The optimization you're speaking of is actually quite easy. You start by subdividing the screen into 4 quadrants, and compute the color of every pixel of the outline of each quadrant (just a rectangle). If any of the rectangles contain a value that is different than the others, you subdivide that rectangle and repeat the process. If all the pixels on the boundary of the rectangle are the same, you just fill with the solid color and move on. Below the first few levels of subdivision, you hit a lot of rectangles that are solid-filled, so it can be quite a large speedup.
I wrote a real-time Julia set once using a few different optimization tricks, this being one of them. You moved the mouse to change the parameters of the set, so it was pretty obviously realtime. [noparse]:)[/noparse]
Jason
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontrolled.
is when the values get too large --> when ints threaten to overflow.
Someone should do this; 8-way (initially, perhaps, each cog gets a scanline) and
a quick int recasting and just see how it goes.
I too coded up a Mandelbrot program many years ago on the Amiga.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontrolled.
Here's what I had, before I gave up and switched to floating point: