Alternate Values

Home • Gallery • Tutorials • Download • Purchase • Site Map
 

Alternate Values Overview

Alternate Values are Fractal Science Kit fractal generator programs that define an alternate value mappings in Mandelbrot Fractals. Alternate value mappings are available as sample data values and as SamplePointValue options in the instructions for the Classic [Master] Controllers and the Orbit Trap [Master] Controllers.

See also:

Each program is composed of a set of properties and instructions.

Comments

Always remember to click the Toggle Code View toolbar button at the top of the Program Editor and read the comments given in the comment section of the program's instructions. The comment section contains usage instructions, hints, notes, documentation, and other important information that will help you understand how best to use the program. Once you are done reading the comments, click the Toggle Code View toolbar button again to view the program's properties.

Properties

Fractal Science Kit - Alternate Values Properties

The following properties are supported:

  • Add Trans Array is a checkbox that can be checked to add a Transformation Array editor as one of the program's properties pages. Users can add 1 or more transformations to the editor and your program can access the transformations using the Transformation Functions.

  • Force Execution is a checkbox that can be checked to force execution of the instructions. If Force Execution is unchecked, the instructions will execute only if required based on what changes were made to the fractal's properties since the last time the instructions ran. This is rarely checked.

Instructions

The remainder of this page can be ignored if you are not a programmer.

At the bottom of the window is an editor pane named Instructions. The editor pane is a simple text editor to view/edit your Program Instructions. See Editing Text for details.

The instructions are divided into sections. Within each section are statements that conform to the Programming Language syntax.

In addition to the Standard Sections, Alternate Values support 3 other sections:

initialize:
iterate:
finalize:

The initialize section is executed once per pixel, just prior to beginning the orbit. Instructions that need to execute at the beginning of each orbit should be placed here. The iterate section is executed once per iteration. The finalize section is executed at the end of each orbit and is the primary section of the program.

The finalize section of the program is responsible for setting alternatePoint based on information derived from the set of orbit points associated with the pixel. alternatePoint is an AlternatePointInfo object defined as:

Object AlternatePointInfo {
  Value
  Angle
  Index
}

Value is an arbitrary floating point value. Angle is a radian angle between -Math.PI and Math.PI. Index is a small integer value between 0 and 32767. Programs can set 1, 2, or all 3 of these values as required. These values are accessed by the Classic [Master] Controllers and the Orbit Trap [Master] Controllers, and used to map a given sample to a color.

Example:

comment:
 
  Based on an algorithm by Ron Barnett.
 
  Turn off histogram equalization and use transfer
  function of Log with Power = 4 for best results.
   
  The iterate: section is only executed if z is less
  than Bailout for divergent fractals, or greater
  than Epsilon for convergent fractals.
 
  alternatePoint.Value is set to the smoothed value.
  alternatePoint.Angle is not used.
  alternatePoint.Index is not used.

initialize:
 
  sum = 0
 
iterate:
 
  switch (FractalEquationType) {
   
    case FractalEquationTypes.Divergent
      sum += Exp(-Abs(z))
     
    case else
      sum += Exp(-1/(Abs(z - zprev1)))
  }
 
finalize:
 
  alternatePoint.Value = sum
 
properties:
 
  #include FractalEquationTypes

This program generates an alternate mapping using Exponential Smoothing. The Angle and Index fields are not set by the program so you cannot use those fields in the associated controller. The iterate section accumulates a value computed from the orbit points based on the fractal's type (Divergent, Convergent, or ConvergentOrDivergent). The finalize section sets the Value to the accumulated data collected in the iterate section.

Example:

comment:
 
  Based on an algorithm by Ron Barnett.
 
  Turn off histogram equalization and use transfer
  function of Log with Power = 4 for best results.
 
  This optimized version eliminates the iterate: section
  for improved performance. All calculations are done
  in the finalize: section using the Orbit.Point function.
 
  The iterate: section is only executed if z is less than
  Bailout for divergent fractals, or greater than
  Epsilon for convergent fractals, so we set imax
  below to include only those points that would have
  been processed by the iterate: section.
 
  alternatePoint.Value is set to the smoothed value.
  alternatePoint.Angle is not used.
  alternatePoint.Index is not used.

finalize:
 
  imax = IIf(IsPointInSet, dwell, dwell-1)
  sum = 0
 
  switch (FractalEquationType) {
   
    case FractalEquationTypes.Divergent
      for (i = 1, i <= imax, i += 1) {
        p = Orbit.Point(i)
        sum += Exp(-Abs(p))
      }
     
    case else
      q = Orbit.Point(0)
     
      for (i = 1, i <= imax, i += 1) {
        p = Orbit.Point(i)
        sum += Exp(-1/(Abs(p - q)))
        q = p
      }
  }
  alternatePoint.Value = sum
   
properties:
 
  #include FractalEquationTypes

This example is identical to the 1st but is more efficient since it has no iterate section. Remember that the iterate section is run on every iteration so is far more expensive than the initialize or finalize sections that are run only once per orbit. By making use of the Orbit Function Orbit.Point and looping over the orbit in the finalize section, we are able to avoid the iterate section altogether which greatly improves performance.

Example:

comment:
 
  Returns the average angle of all trapped points in
  each orbit. The trapped points in an orbit can be
  accessed in the finalize: section using the functions:
  - Trap.Count() which returns the number of trapped points
  - Trap.Value(n) which returns the trap value
  - Trap.Angle(n) which returns the trap angle
  - Trap.Index(n) which returns the trap index
  - Trap.Delta(n) which returns the trap delta
  where 0 <= n < Trap.Count().
 
  alternatePoint.Value is set to the average angle.
  alternatePoint.Angle is not used.
  alternatePoint.Index is not used.
 
finalize:
 
  if (Trap.Count() = 0) {
    alternatePoint.Value = 0
  } else {
    p = 0
   
    for (i = 0, i < Trap.Count(), i += 1) {
      p += Cis(Trap.Angle(i))
    }
    alternatePoint.Value = Arg(p)
  }

This example illustrates how to access raw orbit trap data within your program. The Trap Functions are available only in the finalize section of your program. This example computes the average of the Trap.Angle values over all trapped points for the associated pixel and sets alternatePoint.Value to this value. This feature is rarely used since it is much more convenient to use the built-in features of the Fractal Science Kit to process orbit trap data but does provide a level of flexibility not available otherwise, since you have access to the data for all the trapped points. Normally these points are processed by the Fractal Science Kit based on the orbit trap subsystem properties and a single point is available to the controllers.

Built-in Variables

Several built-in variables are available to your instructions:

  • AlternatePointInfo alternatePoint
  • z
  • c
  • dwell
  • pixel
  • zprev1
  • zprev2
  • smoothingFactor
  • isPointInSet

The built-in variable alternatePoint is used to return the results computed by the program. All of the remaining variables are read-only.

The variables z and c are the same as given in the Fractal Equation. dwell is the current dwell value. The 1st time the iterate section is called, dwell=1, the 2nd time, dwell=2, and so on. This is different than in the Fractal Equation where the 1st time the iterate section is called dwell=0. This is due to the fact that the dwell is incremented after the Fractal Equation computes each orbit point but before the iterate section for the Alternate Value is executed. pixel is the point on the complex plane associated with the orbit. zprev1 and zprev2 are the previous 2 values of z in the current orbit.

isPointInSet is true if the point is considered part of the Mandelbrot set and false if the point escaped. isPointInSet is available only in the finalize section of the program.

smoothingFactor is a value that ranges from 0 to 1 within each dwell and can be used for smoothing the dwell values so the transitions between dwells are not apparent. smoothingFactor is valid only in the finalize section of the program and only if isPointInSet is false.

Example:

finalize:
 
  if (~IsPointInSet) {
    magnitude = dwell - 1 + smoothingFactor
  }

The magnitude above smoothly transitions from 0 to Max Dwell over the fractal. See the built-in alternate mapping Continuous Potential for the formula used to compute smoothingFactor.

In addition to zprev1 and zprev2, you can access the entire set of orbit points computed thus far using the Orbit Functions.

Constants

The following constants are available to your instructions:

  • MagnitudeBailout
  • MagnitudeEpsilon
  • MagnitudeValueExpression
  • MagnitudeReferencePoint
  • AngleReferencePoint
  • FractalEquationType
  • FractalEquationPowerFactor
  • FractalEquationMaxPower
  • ViewportMagnification

These constants provide access to several key property values on the Mandelbrot / Julia / Newton properties page. MagnitudeBailout and MagnitudeEpsilon are the values of the Bailout and Epsilon properties. MagnitudeValueExpression, MagnitudeReferencePoint, and AngleReferencePoint, are the values of the Magnitude, Reference Point, and Angle Reference properties, respectively.

The next 3 constants provide access to properties on the Fractal Equation page. FractalEquationType is the value of the Type property. FractalEquationMaxPower is the value of the Max Power property. FractalEquationPowerFactor is the value of the Power Factor property.

Finally, ViewportMagnification is the current fractal's magnification. The magnification can be viewed by executing the Resize command on the View menu of the Fractal Window.

Of these constants, 4 are given as enums; MagnitudeValueExpression is given as 1 of the DistanceMetricTypes, MagnitudeReferencePoint is given as 1 of the MagnitudeReferencePoints, AngleReferencePoint is given as 1 of the AngleReferencePoints, and FractalEquationType is given as 1 of the FractalEquationTypes. The definitions of these enums can be accessed by including 1 or more #include statements in your properties section as shown below.

Example:

properties:
 
  #include DistanceMetricTypes
  #include MagnitudeReferencePoints
  #include AngleReferencePoints
  #include FractalEquationTypes

The above example includes all 4 enums which are defined in the built-in macros so that the other sections of your program can access the enum values. The definitions of these enums are included here for reference:

#define DistanceMetricTypes

enum DistanceMetricTypes {
  X2addY2,       "x^2 + y^2"
  X2,            "x^2"
  Y2,            "y^2"
  MinX2Y2,       "Min( x^2, y^2 )"
  MaxX2Y2,       "Max( x^2, y^2 )"
  MinAbsXAbsY,   "Min( |x|, |y| )"
  MaxAbsXAbsY,   "Max( |x|, |y| )"
  AbsXaddAbsY2,  "( |x| + |y| )^2"
  AbsXsubAbsY2,  "( |x| - |y| )^2"
  AbsXaddAbsY,   "| |x| + |y| |"
  AbsXsubAbsY,   "| |x| - |y| |"
  AbsX3addAbsY3, "| |x^3| + |y^3| |"
  AbsX3subAbsY3, "| |x^3| - |y^3| |"
  X2subY2,       "| x^2 - y^2 |"
  XmulY,         "| x * y |"
}
#end

#define MagnitudeReferencePoints

enum MagnitudeReferencePoints {
  Origin,                        "Origin"
  PreviousOrbitPoint,            "Previous Orbit Point"
  PreviousMagnitudeCurrentAngle, "Previous Magnitude, Current Angle"
  PreviousAngleCurrentMagnitude, "Previous Angle, Current Magnitude"
}
#end

#define AngleReferencePoints

enum AngleReferencePoints {
  Origin,                   "Origin"
  PreviousOrbitPoint,       "Previous Orbit Point"
  SecondPreviousOrbitPoint, "Second Previous Orbit Point"
}
#end

#define FractalEquationTypes

enum FractalEquationTypes {
  Divergent,             "Divergent"
  Convergent,            "Convergent"
  ConvergentOrDivergent, "Convergent or Divergent"
}
#end

The Exponential Smoothing example at the beginning of this section uses the FractalEquationType property and the FractalEquationTypes enum to control processing based on the fractal's type.

 

Copyright © 2004-2016 Hilbert, LLC
All rights reserved