# Fractals/Iterations in the complex plane/orbit trap

In mathematics, an **orbit trap** is a method of colouring fractal images based upon how close an iterative function, used to create the fractal, approaches a geometric shape, called a "trap".
Orbit traps are typically used to colour two dimensional fractals representing the complex plane.

## Types edit

Typical traps are:

- points (Pnt)
- lines
- circles (Cir and Cr2)
- flower shapes
- even raster images.
- hypercross (Hyp)
- cross or "plus" (Pls)
- rectangle (Rct)
- spiral (Spi).

## Examples edit

### Point based edit

A point based orbit trap colours a point based upon how close a function's orbit comes to a single point, typically the origin.

### Line based edit

A line based orbit trap colours a point based upon how close a function's orbit comes to one or more lines, typically vertical or horizontal (x=a or y=a lines). Pickover stalks are an example of a line based orbit trap which use two lines.

**Pickover stalks** ^{[1]}are certain kinds of details to be found empirically in the Mandelbrot set, in the study of fractal geometry.^{[2]} They are so named after the researcher Clifford Pickover, whose "epsilon cross" method was instrumental in their discovery. An "epsilon cross" is a cross-shaped orbit trap.

According to Vepstas (1997) "Pickover hit on the novel concept of looking to see how closely the orbits of interior points come to the x and y axes. In these pictures, the closer that the point approaches, the higher up the color scale, with red denoting the closest approach. The logarithm of the distance is taken to accentuate the details".^{[3]}

#### Biomorphs edit

Biomorphs are biological-looking Pickover Stalks.^{[4]} At the end of the 1980s, Pickover developed biological feedback organisms similar to Julia sets and the fractal Mandelbrot set.^{[5]} According to Pickover (1999) in summary, he "described an algorithm which could be used for the creation of diverse and complicated forms resembling invertebrate organisms. The shapes are complicated and difficult to predict before actually experimenting with the mappings. He hoped these techniques would encourage others to explore further and discover new forms, by accident, that are on the edge of science and art".^{[6]}

Pickover developed an algorithm (which uses neither random perturbations nor natural laws) to create very complicated forms resembling invertebrate organisms. The iteration, or recursion, of mathematical transformations is used to generate biological morphologies. He called them "biomorphs." At the same time he coined "biomorph" for these patterns, the famous evolutionary biologist Richard Dawkins used the word to refer to his own set of biological shapes that were arrived at by a very different procedure. More rigorously, Pickover's "biomorphs" encompass the class of organismic morphologies created by small changes to traditional convergence tests in the field of "Julia set" theory.^{[6]}

Pickover's biomorphs show a self-similarity at different scales, a common feature of dynamical systems with feedback. Real systems, such as shorelines and mountain ranges, also show self-similarity over some scales. A 2-dimensional parametric 0L system can “look” like Pickover's biomorphs.^{[7]}

## Algorithm edit

Orbit traps are typically used with the class of two-dimensional fractals based on an iterative function. A program that creates such a fractal colours each pixel, which represent discrete points in the complex plane, based upon the behaviour of those points when they pass through a function a set number of times.

The best known example of this kind of fractal is the Mandelbrot set, which is based upon the function *z*_{n+1} = *z*_{n}^{2} + *c*. The most common way of colouring Mandelbrot images is by taking the number of iterations required to reach a certain bailout value and then assigning that value a colour. This is called the escape time algorithm.

A program that colours the Mandelbrot set using a point-based orbit trap will assign each pixel with a “distance” variable, that will typically be very high when first assigned:

```
double distance = 10e5
```

As the program passes the complex value through the iterative function it will check the distance between each point in the orbit and the trap point. The value of the distance variable will be the shortest distance found during the iteration:

```
private double getDistance(Complex c,
Complex point,
int maxIteration)
{
double distance = 1e20;
Complex z = new Complex(0, 0);
for(int i=0; i<maxIteration; i++)
{
//Perform Mandelbrot iteration
z = z.multiply(z);
z = z.add(c);
//Set new distance dist = min( dist, |z-point| )
Complex zMinusPoint = new Complex(z);
zMinusPoint = zMinusPoint.subtract(point);
double zMinusPointModulus = zMinusPoint.magnitude();
if(zMinusPointModulus < distance)
distance = zMinusPointModulus;
}
return distance;
}
```

## code edit

```
// Created by inigo quilez - iq/2013
// https://www.youtube.com/c/InigoQuilez
// https://iquilezles.org/articles/ftrapsbitmap/
// https://www.shadertoy.com/view/4slGWH
// Instead of using a pont, circle, line or any mathematical shape for traping the orbit
// of fc(z), one can use any arbitrary shape. For example, a NyanCat :)
//
// I invented this technique more than 10 years ago (can have a look to those experiments
// here https://iquilezles.org/articles/ftrapsbitmap).
vec4 getNyanCatColor( vec2 p, float time )
{
p = clamp(p,0.0,1.0);
p.x = p.x*40.0/256.0;
p.y = 0.5 + 1.2*(0.5-p.y);
p = clamp(p,0.0,1.0);
float fr = floor( mod( 20.0*time, 6.0 ) );
p.x += fr*40.0/256.0;
return texture( iChannel0, p );
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 p = (2.0*fragCoord-iResolution.xy)/iResolution.y;
float time = max( iTime-5.5, 0.0 );
// zoom
p = vec2(0.5,-0.05) + p*0.75 * pow( 0.9, 20.0*(0.5+0.5*cos(0.25*time)) );
vec4 col = vec4(0.0);
vec3 s = mix( vec3( 0.2,0.2, 1.0 ), vec3( 0.5,-0.2,0.5), 0.5+0.5*sin(0.5*time) );
// iterate Jc
vec2 c = vec2(-0.76, 0.15);
float f = 0.0;
vec2 z = p;
for( int i=0; i<100; i++ )
{
if( (dot(z,z)>4.0) || (col.w>0.1) ) break;
// fc(z) = z² + c
z = vec2(z.x*z.x - z.y*z.y, 2.0*z.x*z.y) + c;
col = getNyanCatColor( s.xy + s.z*z, time );
f += 1.0;
}
vec3 bg = 0.5*vec3(1.0,0.5,0.5) * sqrt(f/100.0);
col.xyz = mix( bg, col.xyz, col.w );
col *= step( 2.0, iTime );
col += texture( iChannel1, vec2(0.01,0.2) ).x * (1.0-step( 5.5, iTime ));
fragColor = vec4( col.xyz,1.0);
}
```

## References edit

- Carlson, Paul W. (1999), "Two artistic orbit trap rendering methods for Newton M-set fractals",
*Computers & Graphics*,**23**(6): 925–931, doi:10.1016/S0097-8493(99)00123-5. - Lu, Jian; Ye, Zhongxing; Zou, Yuru; Ye, Ruisong (2005), "Orbit trap rendering methods for generating artistic images with crystallographic symmetries",
*Computers & Graphics*,**29**(5): 787–794, doi:10.1016/j.cag.2005.08.008.

# Examples edit

- Orbit Trap Fractals by Malin Christersson 2015-12-14
^{[8]} - khanacademy : orbit-traps
- youtube : Mandelbrot Orbit Trap Rendering! Programming How-To
- i quilezles : f traps geometric
- bitmap orbit traps - 2002
- geometric orbit traps - 1999
- procedural orbit traps - 2002
- Shadertoy

# References edit

- ↑ wikipedia : Pickover stalk
- ↑ Peter J. Bentley and David W. Corne (2001).
*Creative Evolutionary Systems*. Morgan Kaufmann. p. 354. - ↑ Linas Vepstas (1997). "Interior Sketchbook Diary". Retrieved 8 July 2008.
- ↑ Paul Nylander. Mandelbrot Set Biomorph. feb 2005. Retrieved 8 July 2008.
- ↑ Edward Rietman (1994).
*Genesis Redux: Experiments Creating Artificial Life*. Windcrest/McGraw-Hill. p. 154. - ↑
^{a}^{b}Clifford A. Pickover (1991) "Accident, Evolution, and Art". YLEN NEWSLETTER number. 12 volume 19 Nov/Dec. 1999. - ↑ Alfonso Ortega, Marina de la Cruz, and Manuel Alfonseca (2002). "Parametric 2-dimensional L systems and recursive fractal images: Mandelbrot set, Julia sets and biomorphs". In:
*Computers & Graphics*Volume 26, Issue 1, February 2002, Pages 143-149. - ↑ OrbitTraps by Malin Christersson