Mandelbrot - ObjectVision/GeoDMS GitHub Wiki

Miscellaneous functions Mandelbrot

The Mandelbrot function generates the Mandelbrot set fractal as a raster image.

syntax

Mandelbrot(gridDomain: SPoint unit, countRange: UInt32 unit, origin: {Void}->DPoint, increment: {Void}->DPoint) -> gridDomain->UInt32

definition

Computes the Mandelbrot set iteration count for each cell in a grid. The Mandelbrot set is defined by the iteration z(n+1) = z(n)² + c, starting with z(0) = c.

For each grid cell:

  1. Map cell coordinates to complex plane position using origin and increment
  2. Iterate until |z| > 2 (escaped) or maximum count reached
  3. Return the iteration count (higher = closer to Mandelbrot set boundary)

Cells inside the Mandelbrot set return maxCount; cells outside return the escape iteration.

arguments

argument description type
gridDomain Domain unit for the result grid (SPoint range) SPoint unit
countRange Maximum iteration count unit UInt32 unit
origin Complex plane origin (maps to grid top-left) {Void}->DPoint
increment Complex plane step per grid cell {Void}->DPoint

The DPoint arguments use:

  • X component → Real part of complex number
  • Y component → Imaginary part of complex number

performance

Time complexity: O(n × maxCount) worst case, where n is the number of grid cells.

In practice, many cells escape quickly, so average performance is much better. The computation is embarrassingly parallel and benefits from multiple cores.

conditions

  • gridDomain must be an SPoint (Int16 point) range
  • countRange determines the maximum iteration count (higher = more detail, slower)
  • origin and increment must have Void domain (parameter values)

example

// Create a 800x600 grid centered on the Mandelbrot set
unit<SPoint> MandelbrotGrid := range(SPoint, point_xy(0s, 0s), point_xy(800s, 600s));
unit<UInt32> IterationRange := range(UInt32, 0, 256);  // max 256 iterations

parameter<DPoint> origin    := point_xy(-2.5, -1.2);   // complex plane origin
parameter<DPoint> increment := point_xy(0.004, 0.004); // 0.004 per pixel

attribute<UInt32> fractal (MandelbrotGrid) := Mandelbrot(
    MandelbrotGrid,
    IterationRange,
    origin,
    increment
);

// Visualize with color palette based on iteration count

visualization

The resulting iteration counts can be visualized by:

  • Mapping counts to a color palette
  • Using logarithmic scaling for better contrast
  • Applying smooth coloring techniques

Classic Mandelbrot set views:

  • Full set: origin=(-2.5, -1.2), range ~3.5
  • Seahorse valley: origin=(-0.75, 0.1), range ~0.1
  • Spiral: origin=(-0.761574, -0.0847596), range ~0.0001

see also

since version

5.0

⚠️ **GitHub.com Fallback** ⚠️