mmf
Class MMF_FormulaTransformWrapper

Object
  extended by common:Generic
      extended by common:Formula
          extended by common:ConvergentDivergentFormula
              extended by mmf:MMF_FormulaTransformWrapper

class 
ConvergentDivergentFormula:MMF_FormulaTransformWrapper

A formula that wraps two transforms around any formula iteration.

Note that for historical reasons this formula uses its own zold and bailout values instead of those defined in the base class doing so should not be taken as a model for other formulas.


Ultra Fractal Source

Toggle UF Source Code Display

 class MMF_FormulaTransformWrapper(common.ulb:ConvergentDivergentFormula) {
 ; A formula that wraps two transforms around any formula iteration.<p>
 ; Note that for historical reasons this formula uses its own
 ; zold and bailout values instead of those defined in the base class
 ; doing so should not be taken as a model for other formulas.<br>
 public:
   import "common.ulb"
   import "Standard.ulb"
 
   ; @param pparent the parent, generally "this" for the parent, or zero
   func MMF_FormulaTransformWrapper(Generic pparent)
     ConvergentDivergentFormula.ConvergentDivergentFormula(pparent)
     fFormula = new @classFormula(this)
     fPreTransform = new @classPreTransform(this)
     fPostTransform = new @classPostTransform(this)
   endfunc
 
   complex func Init(complex pz)
 ;    m_Iterations = 0 not used in this formula
     m_BailedOut = false
     fPreTransform.Init(pz)
     fPostTransform.Init(pz)
     return fFormula.Init(pz)
   endfunc
   
   complex func Iterate(complex pz)
     fZold  = pz
 ;    m_Iterations = m_Iterations + 1 not used in this formula
     return fPostTransform.Iterate(fFormula.Iterate(fPreTransform.Iterate(pz)))
   endfunc
 
   complex func GetPrimaryExponent()
     return fFormula.GetPrimaryExponent()
   endfunc
 
   bool func IsBailedOut(complex pz)
     if ((@p_BailType=="Divergent" || @p_BailType=="Both" \
          || @p_BailType=="Div.+Abs.Conv.") \
         && |pz|>=@p_Bailout) \
        || ((@p_BailType=="Convergent" || @p_BailType=="Both") \
            && |pz-fZold|<=@p_SmallBail) \
        || ((@p_BailType=="Absolute Convergence" \
             || @p_BailType=="Div.+Abs.Conv.") \
            && |pz-@p_root|<=@p_SmallBail )
       m_BailedOut = true
     endif
     return m_BailedOut
   endfunc
 
   float func GetUpperBailout()
     return @p_Bailout
   endfunc
 
   float func GetLowerBailout()
     return @p_SmallBail
   endfunc
 
 protected:
   Formula fFormula
   UserTransform fPreTransform
   UserTransform fPostTransform
   complex fZold
 
 default:
   title = "Formula Transformations"
   int param v_mmfformulatransformwrapper
     caption = "Version (MMF_FormulaTransformWrapper)"
     default = 100
     hint = "This version parameter is used to detect when a change has \
             been made to the formula that is incompatible with the \
             previous version. When that happens, this field will reflect \
             the old version number to alert you to the fact that an \
             alternate rendering is being used."
     visible = @v_mmfformulatransformwrapper < 100
   endparam
   complex param p_power
     visible = false
   endparam
   float param p_upperbailout
     visible = false
   endparam
   float param p_lowerbailout
     visible = false
   endparam
   heading
     caption = "Bailout Options"
     text = "You should note that the bailout options and values you set \
             here will override the bailout settings in the 'Formula' \
             parameters. This is because your chosen transforms may cause \
             a divergent formula to become convergent or vice-versa."
   endheading
   int param p_BailType
     caption = "Bailout Type"
     enum = "Divergent" "Convergent" "Both" "Absolute Convergence" \
            "Div.+Abs.Conv."
     default = 0
     hint = "If you get an empty or nearly empty fractal try switching \
             from 'Divergent' to 'Convergent' or vice-versa or choosing \
             'Both'. Note that in some cases if your fractal is a \
             Mandelbrot you may need to ensure that the zstart value \
             is non-zero."
   endparam
   complex param p_root
     caption = "Convergence Value"
     default = (1,0)
     hint = "This is the value for testing for convergence to. For the \
             'Magnet' formulas the value should be (1,0), if you don't \
             know the value to use it's best to stick to the plain \
             'Convergent' 'Bailout Type'. It's always worth trying (0,0)."
     visible = @p_BailType>2
   endparam
   float param p_Bailout
     caption = "Divergent Bailout"
     default = 128.0
     hint = "In general larger values will require higher iterations."
     visible = @p_BailType==0 || @p_BailType==2 || @p_BailType==4
   endparam
   float param p_SmallBail
     caption = "Convergent Bailout"
     default = 1e-5
     hint = "In general smaller values will require higher iterations."
     visible = @p_BailType>0
   endparam
   heading
     caption = "The Pre-Transform"
     text = "Transforms z on each iteration prior to the main formula \
             calculation."
   endheading
   UserTransform param classPreTransform
     caption = "Pre-Transform"
     default = NullTransform
     hint = "Transforms z on each iteration prior to the main formula \
             calculation."
   endparam
   heading
     caption = "The Main Formula"
   endheading
   Formula param classFormula
     caption = "Formula"
     default = Standard_Mandelbrot
     hint = "The main formula."
   endparam
   heading
     caption = "The Post-Transform"
     text = "Transforms z on each iteration after the main formula \
             calculation."
   endheading
   UserTransform param classPostTransform
     caption = "Post-Transform"
     default = NullTransform
     hint = "Transforms z on each iteration after the main formula \
             calculation."
   endparam
 }
 


Constructor Summary
MMF_FormulaTransformWrapper()
           
MMF_FormulaTransformWrapper(Generic pparent)
           
 
Method Summary
 float GetLowerBailout()
          Determine the lower bailout boundary.
 complex GetPrimaryExponent()
          Determine the primary exponent.
 float GetUpperBailout()
          Determine the upper bailout boundary.
 complex Init(complex pz)
          Set up for a sequence of values
 boolean IsBailedOut(complex pz)
          Test whether the formula has bailed out (i.e.
 complex Iterate(complex pz)
          Produce the next value in the sequence
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

MMF_FormulaTransformWrapper

public MMF_FormulaTransformWrapper(Generic pparent)
Parameters:
pparent - the parent, generally "this" for the parent, or zero

MMF_FormulaTransformWrapper

public MMF_FormulaTransformWrapper()
Method Detail

Init

public complex Init(complex pz)
Description copied from class: ConvergentDivergentFormula
Set up for a sequence of values

This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).

Overrides:
Init in class ConvergentDivergentFormula
Parameters:
pz - seed value for the sequence; for a normal fractal formula, this will be #pixel
Returns:
first value in the sequence; this corresponds to #z in a fractal formula

Iterate

public complex Iterate(complex pz)
Description copied from class: ConvergentDivergentFormula
Produce the next value in the sequence

As long as the sequence has not bailed out, this function will be continually called to produce sequence values.

Overrides:
Iterate in class ConvergentDivergentFormula
Parameters:
pz - previous value in the sequence; corresponds to #z in a fractal formula. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call.
Returns:
the next value in the sequence

GetPrimaryExponent

public complex GetPrimaryExponent()
Description copied from class: Formula
Determine the primary exponent.

Many fractals can be characterized by an exponent value that is useful to other formulas, so we provide that here. If your formula does not need or use this value, override the p_power parameter and make it hidden.

Overrides:
GetPrimaryExponent in class Formula
Returns:
the primary exponent parameter

IsBailedOut

public boolean IsBailedOut(complex pz)
Description copied from class: ConvergentDivergentFormula
Test whether the formula has bailed out (i.e. the sequence is complete)

Since this is a divergent fractal, the test is easy: if it's bigger than the bailout, the sequence is done.

Overrides:
IsBailedOut in class ConvergentDivergentFormula
Parameters:
pz - last sequence value to test; this should be the value returned from the previous Iterate() call. Note that it is acceptable to ignore pz and use m_BailedOut, but any code calling IsBailedOut() should pass in the correct pz for Formula classes which do not use m_BailedOut.
Returns:
true if the sequence has bailed out (i.e. should be terminated)

GetUpperBailout

public float GetUpperBailout()
Description copied from class: ConvergentDivergentFormula
Determine the upper bailout boundary.

Overrides:
GetUpperBailout in class ConvergentDivergentFormula
Returns:
the upper bailout parameter

GetLowerBailout

public float GetLowerBailout()
Description copied from class: ConvergentDivergentFormula
Determine the lower bailout boundary.

Overrides:
GetLowerBailout in class ConvergentDivergentFormula
Returns:
the lower bailout parameter