1. Forums
  2. Discord
  3. About Mapcore
  4. Patreon Supporters
  • Login
  • Register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • More Options
  1. Mapcore
  2. Discussions
  3. Off-Topic

Math makes pretty pictures (Mandelbrot Set)

  • Section_Ei8ht
  • October 1, 2006 at 2:53 PM
  • Section_Ei8ht
    • October 1, 2006 at 2:53 PM
    • #1

    So, for a computer graphics course at college, i wrote a quick program that uses C++ and opengl to display a Mandelbrot Set.

    A Mandelbrot Set is an infinitly complex fractal, so if you "zoom" in on the edge of the set by any factor, the edge remains complex. For more about Mandelbrot Sets, check out the wikipedia article

    My favorite part of the set. Its a renormalization of the set that occurs in the negative quad on the x axis (not sure what the zoom factor is):

    [Blocked Image: http://www.sectionei8ht.com/images/mandelbrot1.jpg]

    Download: MandelbrotSets.exe

    glut32.dll (put this in your windows system32 directory)

    Its pretty simple. An 800x600 window opens and displays the set. You can then use the left mouse button to zoom in on a particular point (factor of 2), the right mouse button to zoom out on a point (again a factor of 2), and the middle mouse button to reset the display to what it was on startup.

    The colors are defined in the code based on how many iterations the pixel is away from the set. As of now, if you want to change the color of the image, you would need to modify the source code.

    A note: If you zoom in far enough, you eventually get to a point where the precision of numbers in the computer is not great enough to perform the calculations, and the image gets extremely pixelated. Also because of the blue color scheme, the closer you get, the harder it gets to distinguish between what is in the set and what is borderline of the set. Changing the colors would fix this.

    If anyone cares enough to want to have a look at the source code, let me know, and I can send it to you (my prof asked me to not make it widely available, because he and other profs use this as an assignment quite often)

    Enjoy. Its worth about 2 minutes of fun. (maybe one of these days I'll add to it with zoom transitions, ability to change colors on the fly, etc.)

    [EDIT]

    Forgot about the glut32.dll. I added a link above.

  • e-freak
    • October 1, 2006 at 8:35 PM
    • #2

    nice stuff - what semester of math study is this? and how complex is this to render? because i think of making sprites out of this dynamically for energy explosions like in crysis

    thought of a photoshop plugin already? with sliders for editable values?

  • hessi
    • October 1, 2006 at 9:40 PM
    • #3
    Quote from e-freak

    nice stuff - what semester of math study is this? and how complex is this to render? because i think of making sprites out of this dynamically for energy explosions like in crysisthought of a photoshop plugin already? with sliders for editable values?

    i know this figure from semester 2 in my math course. fractals/complex numbers (?) are the base of all this rendering clouds stuff we use in photoshop or in a mental ray fractal shader.

    the fun thing is, that you cant calculate a volume for this structure. its like 2,5 dimensional.

    anyway: good work. maybe i will throw it over to my math professor. he always likes to show practical applications to his "boring"(it was pretty interesting due to examples like this one) math

  • Section_Ei8ht
    • October 1, 2006 at 10:54 PM
    • #4

    Thanks for the comments

    The math involved wasn't all that complex. The last math course I took was calc 1. The hardest part was converting pixel coordinates to cartesian coordinates. The point of the assignment was more to get us used to working with the fundamentals of OpenGL (kinda need those for an OpenGL class )

    The rendering time depends on how many iterations you use to test whether or not a point is in the set; the more iterations, the more exact you are to a true mandelbrot set. I'm using 1000 iterations through the function to determine if a point is in the set, and if you zoom in to the center where all points are in the set, it becomes 1000 iterations for every pixel on the screen. I'd imagine with a few optimizations and alterations, this could be easy to render for sprites.

    e-freak, I like your idea about a photoshop plugin. It would give me an excuse to learn how to make them

  • Izuno
    • October 2, 2006 at 1:49 AM
    • #5

    back when i was in highschool in the 20th century I did my sophomore year science fair project was on the Mandelbrot set. back then our computer was old and we wrote our own Mandelbrot software in Turbo Pascal (no really, it was Turbo Pascal) that we found in an issue of Scientific American.

    Our resolution was 480 x 480 and we only had 8 bit color or something, with a N of 244 or 256 (n= iteration limit in Mandelbrot calculations) anyway, a full screen at very close magnification near the set boundary would take 12 to 16 hours to calculate due to the computer's lack of power. The caclulation is an iterative computation on points on the complex plain of numbers.

    The basic theory is that when you perform the iterative calculation on a point in the complex plain, once the iteration result magnitude goes above 2, it will spinn off to infinity. Less than 2, it is impossible to exactly predict how many iterations it will take to go above 2, if at all.

    The actual "set" of the mandelbrot set is the collection of Complex numbers that NEVER yield magnitudes that go above 2 when the iterative calculation is applied to them.

    There are many startling properties of the Mandelbrot Set, but that's for another post perhaps. Anyway, the set is considered the most compelx object in mathematics, possibly including all of nature.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!

Register Yourself Login
Discord

The Mapcore Discord is our lively IRC channel of the 2000s reborn. Chat about level design, gaming, and more.

Latest Posts

  1. Custom Gamemodes Contest

    Angel
    July 20, 2026 at 11:46 AM
  2. FAQ

    Angel
    July 20, 2026 at 10:14 AM
  3. Tangerine

    Harry Poster
    July 18, 2026 at 11:10 AM
  4. Any of the old guard still around? D:

    Warby
    July 12, 2026 at 8:23 PM
  5. About our archived forums

    Thrik
    June 30, 2026 at 2:12 PM
  6. Mapcore Discord

    mason_fan123
    June 24, 2026 at 8:52 PM
  7. [CS2] Valley

    Serialmapper
    June 22, 2026 at 11:56 AM
  8. Free Music / SFX Resource - Over 2500 Tracks

    Eric Matyas
    June 18, 2026 at 12:32 PM
  9. Pango [WIP]

    Elowen
    June 11, 2026 at 10:13 AM
  10. [CS2] Dvina

    Jeremy Rivera
    June 11, 2026 at 10:03 AM
  1. Privacy Policy
  2. Contact
Powered by WoltLab Suite™