ChaosPro Home
Introduction
What's New
Palettes
Using Formulas
Layering in ChaosPro
Rendering
Fractal Parameter Windows
Windows
Menu
3D Transformations
Animations
Formula Compiler
Writing Formulas
Language Reference
Introduction
Basic Syntax
Datatypes
Constants
Variables
Expressions
Operators
Functions
Control Structures
Compiler Directives
Functions
Interface to ChaosPro
Escapetime Formulas
Quaternion Formulas
Attractor Formulas
Iteration Formulas
Coloring Formulas
Libraries
How it works together
Description function
Special Features, Notes...
Compatibility
Fractal Type Reference
Tutorials
Appendix
CHAOSPRO 4.0
Release 4.0
.

Attractor - Pixel Transformations

Pixel transformation formulas (i.e. iteration formulas) are the most important formulas in ChaosPro: They calculate a new 3D point based on another 3D point, in other words: They take the 3D point present in the variable z and somehow calculate a new 3D point and assign it to z. So this formula is responsible for the complexity of the fractal, i.e. the detail level and its shape.

How the next 3D point actually is calculated is completely upto the formula author.

Such a pixel transformation formula can contain the following functions:

  • void init_once(void): Called only once, i.e. when the fractal calculation starts: In this routine you can initialize variables and allocate arrays.
  • void init(void): This init routine is executed once when the iteration starts. Its purpose is to do some initializations for the formula. Please remember that variables do not have an initial value. They are uninitialized and contain random values at the beginning. So initialize them in this function or in init_once...
  • void loop(void): This function defines the main iteration formula.

    After the init function the main iteration loop starts: This function gets executed until the maximum number of iterations has been reached.

  • real scale(void): This is a special function which is not used during rendering: It is used when you click onto the "Search" button and ChaosPro chooses random parameters in order to find a new interesting set of parameters. Normally (i.e. if you do not define a scale function...) ChaosPro tries to simply determine the Lyapunov exponent for the resulting attractor in order to determine whether the fractal can be drawn or is just a simple contractive object which results in a few points or is expansive, i.e. cannot be drawn because the points of the attractor tend to go to infinity. But sometimes calculating the Lyapunov exponent goes wrong...and perhaps the formula author himself knows something about the formula. In that case it's a good idea to implement the scale() function: It should return a value which specifies the average contraction/expansion factor for the fractal: A value <1 indicates that the fractal is contractive, a value >1 indicates that the fractal is expansive. ChaosPro assumes a fractal is "nice" if the factor is from the interval [0..1[
  • void description(void): An iteration formula also may (must) contain a function named description.

In order to tell ChaosPro that this formula is ment for fractal type Attractor (and thus the proper predefined variables are defined), you need to specify the keyword ATTRACTOR in brackets after the formula identifier. This tells ChaosPro that pixel and z are quaternion variables (instead of complex variables) and that the other predefined variables for this fractal type are defined.

Example

Pickover(ATTRACTOR)
{
parameter real A,B,C,D;
real xNew,yNew,zNew;
real xO,yO,zO;
shared vector zOld;

	void init(void)
	{
		z=(1,1,1);
	}
	void loop(void)
	{
		zOld=z;
		xO=partx(z);
		yO=party(z);
		zO=partz(z);
		xNew=sin(A*yO)-zO*cos(B*xO);
		yNew=zO*sin(C*xO)-cos(D*yO);
		zNew=sin(xO);
		
		z=vector(xNew,yNew,zNew);
	}
	bool stop(void)
	{
		return(false);
	}
	void description(void)
	{
		this.title="Pickover";
		this.helpfile = "ChaosPro.chm";
		this.helptopic = "Iteration Formula";
		this.maxiter=20000;

		A.caption="A";
		A.default=1;
		A.randomizable=true;
		A.min=-3;
		A.max=3;

		B.caption="B";
		B.default=1.8;
		B.randomizable=true;
		B.min=-3;
		B.max=3;
     
		C.caption="C";
		C.default=0.71;
		C.randomizable=true;
		C.min=-3;
		C.max=3;

		D.caption="D";
		D.default=1.51;
		D.randomizable=true;
		D.min=-3;
		D.max=3;

	}
}