mmf
Class MMF_SwitchFormulaTransformWrapper

Object
  extended by common:Generic
      extended by common:Formula
          extended by common:ConvergentDivergentFormula
              extended by mmf:MMF_SwitchConvergentDivergentFormula
                  extended by mmf:MMF_SwitchFormulaTransformWrapper

class 
MMF_SwitchConvergentDivergentFormula:MMF_SwitchFormulaTransformWrapper

A formula that wraps two transforms around any formula iteration.
With switching when used with mmf5.ufm-Generic Switch Formula

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_SwitchFormulaTransformWrapper(MMF_SwitchConvergentDivergentFormula) {
 ; A formula that wraps two transforms around any formula iteration.<br>
 ; With switching when used with mmf5.ufm-Generic Switch Formula<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"
 
   ; @param pparent the parent, generally "this" for the parent, or zero
   func MMF_SwitchFormulaTransformWrapper(Generic pparent)
     MMF_SwitchConvergentDivergentFormula.MMF_SwitchConvergentDivergentFormula(pparent)
     fFormula = new @classFormula(this)
     fPreTransform = new @classPreTransform(this)
     fPostTransform = new @classPostTransform(this)
   endfunc
 
   func SetParams(bool f,complex v)
     if @classFormula==MMF_SwitchFormula
       MMF_SwitchFormula(fFormula).SetParams(f,v)
     elseif @classFormula==MMF_SwitchDivergentFormula
       MMF_SwitchDivergentFormula(fFormula).SetParams(f,v)
     elseif @classFormula==MMF_SwitchConvergentFormula
       MMF_SwitchConvergentFormula(fFormula).SetParams(f,v)
     elseif @classFormula==MMF_SwitchConvergentDivergentFormula
       MMF_SwitchConvergentDivergentFormula(fFormula).SetParams(f,v)
     endif
   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)
 ;    m_Iterations = m_Iterations + 1 not used in this formula
     fZold = pz
     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 = "Switch Formula Transformations"
   rating = recommended
   int param v_mmfswitchformulatransformwrapper
     caption = "Version (MMF_SwitchFormulaTransformWrapper)"
     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_mmfswitchformulatransformwrapper < 100
   endparam
   bool param p_manual
     visible = false
   endparam
   complex param p_power
     visible = false
   endparam
   float param p_upperbailout
     visible = false
   endparam
   float param p_lowerbailout
     visible = false
   endparam
   bool param p_addpixel
     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. To use multiple transforms select 'Transform \
             Merge' from common.ulb."
   endparam
   heading
     caption = "The Main Formula"
   endheading
   heading
     text = "Note that the current 'Formula' is not a switch formula \
             and so will not switch using UFs built-in switch method."
     visible = @classFormula!=MMF_SwitchFormula \
               && @classFormula!=MMF_SwitchDivergentFormula \
               && @classFormula!=MMF_SwitchConvergentFormula \
               && @classFormula!=MMF_SwitchConvergentDivergentFormula
   endheading
   Formula param classFormula
     caption = "Formula"
     default = MMF_SwitchStandard
     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. To use multiple transforms select 'Transform \
             Merge' from common.ulb."
   endparam
 }
 


Constructor Summary
MMF_SwitchFormulaTransformWrapper()
           
MMF_SwitchFormulaTransformWrapper(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)
          Note that here zold is initialised to initial z
 boolean IsBailedOut(complex pz)
          Test whether the formula has bailed out (i.e.
 complex Iterate(complex pz)
          Produce the next value in the sequence
 void SetParams(boolean f, complex v)
           
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

MMF_SwitchFormulaTransformWrapper

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

MMF_SwitchFormulaTransformWrapper

public MMF_SwitchFormulaTransformWrapper()
Method Detail

SetParams

public void SetParams(boolean f,
                      complex v)
Overrides:
SetParams in class MMF_SwitchConvergentDivergentFormula
Parameters:
f - flag for Mandelbrot or Julia mode, is true for Mandelbrots
v - the value to be used as the start value or constant

Init

public complex Init(complex pz)
Description copied from class: MMF_SwitchConvergentDivergentFormula
Note that here zold is initialised to initial z

What it's initialised to is normally irrelevant unless the derived formula uses zold in its main calculations in which case the user should be given the choice of initialising zold to either the location, the initial z value or a fixed constant.

Overrides:
Init in class MMF_SwitchConvergentDivergentFormula
Parameters:
pz - the location (normally #pixel)
Returns:
initial z for iteration

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