common
Class ConvergentDivergentFormula

Object
  extended by common:Generic
      extended by common:Formula
          extended by common:ConvergentDivergentFormula
Direct Known Subclasses:
ConvergentDivergentManyJulia, MMF_FormulaTransformWrapper, MMF_SwitchConvergentDivergentFormula, REB_3RDIMMagnet1, REB_3RDIMMagnet1Julia, REB_3RDIMMagnet2, REB_3RDIMMagnet2Julia, Standard_Magnet1Julia, Standard_Magnet1Mandelbrot, Standard_Magnet2Julia, Standard_Magnet2Mandelbrot

class 
Formula:ConvergentDivergentFormula

Convergent/Divergent Formula base class.

This class extends Formula to provide automatic, simple bailout tests. Formulas for which the outside points converge on points OR grow without bound should derive from this class so as to avoid having to write the bailout tests and the GetUpperBailout() and GetLowerBailout() function.


Ultra Fractal Source

Toggle UF Source Code Display

 class ConvergentDivergentFormula(Formula) {
   ; Convergent/Divergent Formula base class.
   ; <p>
   ; This class extends Formula to provide automatic, simple
   ; bailout tests. Formulas for which the outside points
   ; converge on points OR grow without bound should derive
   ; from this class so as to avoid having to write the
   ; bailout tests and the GetUpperBailout() and
   ; GetLowerBailout() function.
   
 public:
   ; Constructor
   ;
   ; @param pparent a reference to the object creating the new object; typically, 'this'
   func ConvergentDivergentFormula(Generic pparent)
     Formula.Formula(pparent)
   endfunc
   
   ; Set up for a sequence of values
   ; <p>
   ; This function will be called at the beginning of each
   ; sequence of values (e.g. at the beginning of each fractal
   ; orbit).
   ;
   ; @param pz seed value for the sequence; for a normal fractal formula, this will be #pixel
   ; @return first value in the sequence; this corresponds to #z in a fractal formula
   complex func Init(complex pz)
     Formula.Init(pz)
     ; Base class implementation flags the sequence to end
     ; immediately. We clear the flag here.
     m_BailedOut = false
     m_ZOld = pz
     return pz
   endfunc
   
   ; Produce the next value in the sequence
   ; <p>
   ; As long as the sequence has not bailed out, this function
   ; will be continually called to produce sequence values.
   ;
   ; @param 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.
   ; @return the next value in the sequence
   complex func Iterate(complex pz)
     Formula.Iterate(pz)
     ; We need to update our previously-saved Z value.
     m_ZOld = pz
     return pz
   endfunc
 
   ; Test whether the formula has bailed out (i.e. the sequence is complete)
   ; <p>
   ; Since this is a divergent fractal, the test is easy: if it's
   ; bigger than the bailout, the sequence is done.
   ;
   ; @param 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.
   ; @return true if the sequence has bailed out (i.e. should be terminated)
   bool func IsBailedOut(complex pz)
     return |pz| > @p_upperbailout || |pz-m_ZOld| < @p_lowerbailout
   endfunc
 
   ; Determine the upper bailout boundary.
   ;
   ; @return the upper bailout parameter
   float func GetUpperBailout()
     return @p_upperbailout
   endfunc
   
   ; Determine the lower bailout boundary.
   ;
   ; @return the lower bailout parameter
   float func GetLowerBailout()
     return @p_lowerbailout
   endfunc
 
 protected:
   complex m_ZOld
   
 default:
   int param v_convergentdivergentformula
     caption = "Version (ConvergentDivergentFormula)"
     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_convergentdivergentformula < 100
   endparam
 
   float param p_upperbailout
     caption = "Bailout"
     default = 1.0e20
     hint = "Defines how soon an orbit bails out, i.e. doesn't belong to the fractal set anymore. Note: larger values result in more iterations being calculated."
   endparam
   float param p_lowerbailout
     caption = "Bailout"
     default = 1.0e-15
     hint = "Defines how soon an orbit bails out, i.e. doesn't belong to the fractal set anymore. Note: smaller values result in more iterations being calculated."
   endparam
 }
 


Constructor Summary
ConvergentDivergentFormula()
           
ConvergentDivergentFormula(Generic pparent)
          Constructor
 
Method Summary
 float GetLowerBailout()
          Determine the lower bailout boundary.
 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:Formula
GetPrimaryExponent
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

ConvergentDivergentFormula

public ConvergentDivergentFormula(Generic pparent)
Constructor

Parameters:
pparent - a reference to the object creating the new object; typically, 'this'

ConvergentDivergentFormula

public ConvergentDivergentFormula()
Method Detail

Init

public complex Init(complex pz)
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 Formula
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)
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 Formula
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

IsBailedOut

public boolean IsBailedOut(complex pz)
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 Formula
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()
Determine the upper bailout boundary.

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

GetLowerBailout

public float GetLowerBailout()
Determine the lower bailout boundary.

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