Testing Waters
  • Scrapbook
  • Projects
    • Bamiyan Cultural Center
    • Bauhaus Museum
    • Better Hebbal
    • Bicycle Station
    • Cross Laminated Timber
    • Facade
    • Flowing Fabrication
    • Form from Images
    • Guggenheim Helsinki
    • National War Museum
    • National War Memorial
    • Indflorescence
    • Rectangular Compartments
    • Retail Space Layout
    • Noise Barrier : Swedevia Airport
    • Walden
    • Wilson Garden
  • Patterns
    • Area Graph
    • Array along Curve
    • Fibbonacci and Factorial
    • Gyroid
    • Hexagonal Pattern From Image
    • Hexagonal Grid
    • Koch Star
    • Mandelbrot Set
    • Pattern
    • Pattern
    • Pattern
    • Phyllotaxis
    • Random Strip Widths
    • Skewed Surface
    • Staggered Checkerboard
    • Triangle subdivision
    • Vector Field
    • Voronoi
    • Waves
    • Weave
  • Geometry
    • Boundary Curve
    • Bridging parallel curves
    • British Museum Great Court
    • Catenary
    • Delete Adjacent
    • Geodesic Sphere
    • Group Branching Curves
    • Group Circles
    • Group curves
    • K Mean
    • Nurbs Surface Irregular
    • Overlapping Petals
    • Pair Nearest
    • Parametric Shapes
    • Platonic Solids
    • Polyline to PolyArc
    • Roman Surface
    • Sagrada Familia Schools Roof
    • Sine Curve
    • Sine Ribbon
    • Spherical Transformations
    • Split Rectangle
    • Tangential Circle through Point
    • Travelling Salesman Problem
    • Unaligned Bounding Box
  • Lists
    • Alter by Boolean Sequence
    • Color by distance
    • Consecutive Points
    • Distancing
    • Divide Equally
    • Geometry from Image
    • Image based Point Density
    • Isovists
    • Reduce Color Palette
    • Replace Consecutive
    • Replace Multiple
    • Replace Recurring
    • Shadow Area
    • Shortest Path
    • Solar Analysis
    • Topography Analysis
  • Motion
    • Adjacency
    • Animate Sphere
    • Cellular Automation
    • Cloth
    • Hypotrochoid
    • Manakin
    • Rolling Spiral
    • Tan Curve
    • Trammel of Archemedes
    • Image to Integer
  • Articles
    • A Conceptual Approach to Integrating Computational Methods in Early Stage Design
    • Design Script's ambiguous and versatile Replication Guides <1>
    • Design Script's ambiguous and versatile Replication Guides <2>
Powered by GitBook
On this page
  1. Patterns

Mandelbrot Set

PreviousKoch StarNextPattern

Last updated 3 years ago

Mathematically, the Mandelbrot set is defined on the plane of complex numbers


//Function
def mandelbrot(wd,ht,mx)
{
	return [Imperative]
	{
		it = [];
		for (rw in 0..ht-1)
		{
		    for (cl in 0..wd-1)
		    {
		        rl = (cl - wd/2.0)*4.0/wd;
		        im = (rw - ht/2.0)*4.0/wd;
		        x = 0;
		        y = 0;
		        n = 0;
		        while (x*x+y*y <= 4 && n < mx)
		        {
		            x1 = x*x - y*y + rl;
		            y = 2*x*y + im;
		            x = x1;
		            n = n + 1;
		        }
		        it[cl][rw] = n;
		    }
		}
		return it;
	}
};
wd = 200;
hg = 200;
m = mandelbrot(wd,hg,50);

//Visualization
q = List.Reverse(List.Sort(List.UniqueItems(List.Flatten(m,-1))));
r = List.DropItems(Math.Round(Math.RemapRange(q,10,250)),-1);
d = Dictionary.ByKeysValues(q+"", List.Flatten([Color.ByARGB
(250,175,230,125),Color.ByARGB(List.Reverse(r),List.ShiftIndices
(r,100),List.ShiftIndices(r,-13),List.Reverse(r))],-1));
c = Image.FromPixels(List.Transpose(d.ValueAtKey(m+"")));

//Surface
pt1 = Point.ByCoordinates((-wd/2..wd/2..#wd)<1>,(-hg/2..hg/2..#hg)<2>);
el1 = List.Chop(Math.RemapRange(List.Flatten(m,-1),0,hg/10),hg);
sr1 = NurbsSurface.ByControlPoints(pt1.Translate(Vector.ZAxis(),el1));
sr2 = GeometryColor.BySurfaceColors(sr1,d.ValueAtKey(m+""));

Joni "Let’s draw the Mandelbrot set!", November 17, 2013 <https://jonisalonen.com/2013/lets-draw-the-mandelbrot-set/> January 26, 2021

Maximum Iterations: 10
Maximum Iterations: 30