mt
Class MT_Traps

Object
  extended by common:Generic
      extended by common:Formula
          extended by common:DivergentFormula
              extended by mt:MT_Traps

class 
DivergentFormula:MT_Traps

Mark Townsend, June 2008


Ultra Fractal Source

Toggle UF Source Code Display

 class MT_Traps(common.ulb:DivergentFormula) {
 ;
 ; Mark Townsend, June 2008
 ;
 public:
   import "Standard.ulb"
 
   func MT_Traps(Generic pparent)
     fFormula = new @formulaClass(this)
     fTrapShape = new @TrapShapeClass(this)
   endfunc
 
   complex func Init(complex pz)
     complex start = fFormula.Init(pz)
     fTrapShape.Init(pz)
     return start
   endfunc
 
   complex func Iterate(complex pz)
     z = fFormula.Iterate(pz)
     fDis = fTrapShape.Iterate(z)
     return z
   endfunc
   
    bool func IsBailedOut(complex pz)
      if fFormula.IsBailedOut(pz) || fDis < @p_threshold
        m_BailedOut = True
      else
        m_BailedOut = false
      endif
     return m_BailedOut
   endfunc
 
 
 private:
   Formula fFormula
   TrapShape fTrapShape
   float fDis
   
 default:
   title = "Traps"
   float param p_threshold
     caption = "Threshold"
     default = 0.025
     min = 1E-10
   endparam
   Formula param formulaClass
     caption = "Fractal Formula"
     default = Standard_Mandelbrot
   endparam
   TrapShape param TrapShapeClass
     caption = "Trap Shape"
     default = Standard_TrapShapeCross
   endparam
   param p_power
     visible = false
   endparam
   float param p_bailout
     visible = false
   endparam
 }
 


Constructor Summary
MT_Traps()
           
MT_Traps(Generic pparent)
           
 
Method Summary
 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:DivergentFormula
GetUpperBailout
 
Methods inherited from class common:Formula
GetLowerBailout, GetPrimaryExponent
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

MT_Traps

public MT_Traps(Generic pparent)

MT_Traps

public MT_Traps()
Method Detail

Init

public complex Init(complex pz)
Description copied from class: DivergentFormula
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 DivergentFormula
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: Formula
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)
Description copied from class: DivergentFormula
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 DivergentFormula
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)