Skip to content

Python scripts which generate fractals from scratch. I wrote these to get some intuition for recursion. Did you know that the B in Benoit B. Mandelbrot stands for Benoit B. Mandelbrot?

Notifications You must be signed in to change notification settings

jeremy-collins/fractal_generation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fractal_generation

Dragon Curve

This is the shape generated by a thin strip of paper if you were to fold it in half repeatedly, and then unfold all of your folds to 90 degree angles. My inspiration to pursue this project came when I was playing with a straw wrapper at a restaurant.

Alt text

This fractal was generated using Python Turtle graphics as the framework. Essentially, I recursively generate a string of left and right turns which commands a line-drawing agent to trace out the entire fractal. I created the color gradient by fine-tuning the frequency and phase of some fancy sinusoidal functions for the RGB values.

Mandelbrot Set

A classic example of the beauty of mathematics. This fractal was generated by starting with a complex number c between -2 - 2i and 2 + 2i. This complex number is then plugged into the recurrence relation: , where z is the previous output (initialized to 0), and c is the point we are evaluating. A point is in the Mandelbrot set if z does not explode to infinity (diverge) within a given number of iterations (recursion depth).

This recursive relationship is evaluated for every point in the image (except for some of the central bulbs, which I check for analytically to save computation time). Each point is colored by the highest depth at which it continues to be in the Mandelbrot set.

Alt text

When running mandelbrot.py, simply drag your mouse across the screen to make a zoom window and generate a new plot! The depth and resolution are completely configurable.

About

Python scripts which generate fractals from scratch. I wrote these to get some intuition for recursion. Did you know that the B in Benoit B. Mandelbrot stands for Benoit B. Mandelbrot?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages