jlb
Class JLB_SlopeWithShapes

Object
  extended by common:Generic
      extended by common:Formula
          extended by common:DivergentFormula
              extended by mmf:MMF_SwitchDivergentFormula
                  extended by jlb:JLB_SlopeWithShapes

class 
MMF_SwitchDivergentFormula:JLB_SlopeWithShapes

A slope formula that can be used with any object formualas.

Original code modified from Damien M. Jones by Ron Barnett. Uses a special helper class that allows TrapShape plugins for height values


Ultra Fractal Source

Toggle UF Source Code Display

 class JLB_SlopeWithShapes(mmf.ulb:MMF_SwitchDivergentFormula) {
 ; A slope formula that can be used with any object formualas. <br>
 ; <p>
 ; Original code modified from Damien M. Jones by Ron Barnett.
 ; Uses a special helper class that allows TrapShape plugins for height values
 
 public:
   import "common.ulb"
 
   ; constructor
   func JLB_SlopeWithShapes(Generic pparent)
     MMF_SwitchDivergentFormula.MMF_SwitchDivergentFormula(pparent)
     m_BailoutFunc = new @f_bailout(this)
     fHelper[0] = new @helperclass(this)
     fHelper[1] = new @helperclass(this)
     fHelper[2] = new @helperclass(this)
   endfunc
 
   ; initialize the object
   complex func Init(complex pz)
     m_BailoutFunc.Init(@p_bailout)       ; from parent class
     pz = MMF_SwitchDivergentFormula.Init(pz)
     z1 = fHelper[0].Init(pz, fConstant) ; primary iterated point
     fHelper[1].Init(pz + @offset, fConstant) ; horizontally offset point
     fHelper[2].Init(pz + flip(@offset), fConstant) ; vertically offset point
     fIteration = 0
     return z1
   endfunc
 
   ; call for each iterated point. Overrides the parent Iterate function. <br>
   ;  <p>
   ; We can't use the pz value because we need to keep track of three z values.
   ; The helper function manages the pz values and bailout.
   complex func Iterate(complex pz)
     fIteration = fIteration + 1
     z1 = fHelper[0].Iterate(fConstant)
     fHelper[1].Iterate(fConstant)
     fHelper[2].Iterate(fConstant)
     bool BailedOut = IsBailedOut(z1)
     if @everyiter || BailedOut || fIteration == #maxiter
       ; done, or every iteration, or last
       float e1 = fHelper[0].CalcHeight(fIteration)
       float e2 = fHelper[1].CalcHeight(fIteration)
       float e3 = fHelper[2].CalcHeight(fIteration)
       ; determine surface normal
       ; that is, the normal to the surface defined by:
       ; (real(c1), imag(c1), e1)
       ; (real(c2), imag(c2), e2)
       ; (real(c3), imag(c3), e3)
       float vx = e2-e1
       float vy = e3-e1
       float vz = -@offset
       ; normalize vector
       float vd = 1/sqrt(sqr(vx)+sqr(vy)+sqr(vz))
       vx = vx*vd
       vy = vy*vd
       vz = vz*vd
       return vx + flip(vy); fudge z from vector
     else ; didn't compute z this time
       ; use primary iteration value to keep periodicity working
       return z1
     endif
   endfunc
   
   ; @param pz
   ; @return true if bailed out.
   bool func IsBailedOut(complex pz)
     return m_BailoutFunc.Iterate(z1)        ; pz is a normal
   endfunc
 
 private:
   JLB_SlopeHelper fHelper[3]
   int fIteration
   Reduction m_BailoutFunc
   complex z1
 
 default:
   title = "Slope With Shapes"
   int param v_slopeWithShapes
     caption = "Version (Slope With Shapes)"
     default = 101
     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_slopeWithShapes < 101
   endparam
   JLB_SlopeHelper param helperclass
     selectable = false
   endparam
   float param offset
     caption = "Orbit Separation"
     default = 0.00000001
     exponential = true
     hint = "Defines how far apart the simultaneous orbits are.  Smaller \
             distances will produce more accurate results."
   endparam
   bool param everyiter
     caption = "Every Iteration"
     default = false
     hint = "If set, the surface normal will be computed at every \
             iteration.  If you are using a coloring algorithm which \
             processes every iteration, you will need this."
   endparam
   complex param p_power ; Hide p_power from Formula
     visible = false
   endparam
 Heading
  caption = "Bailout"
 Endheading
 
   Reduction param f_bailout
     caption = "Bailout Type"
     default = JLB_SimpleBailout
   endparam
 }
 


Constructor Summary
JLB_SlopeWithShapes()
           
JLB_SlopeWithShapes(Generic pparent)
          constructor
 
Method Summary
 complex Init(complex pz)
          initialize the object
 boolean IsBailedOut(complex pz)
          Test whether the formula has bailed out (i.e.
 complex Iterate(complex pz)
          call for each iterated point.
 
Methods inherited from class mmf:MMF_SwitchDivergentFormula
SetParams
 
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

JLB_SlopeWithShapes

public JLB_SlopeWithShapes(Generic pparent)
constructor


JLB_SlopeWithShapes

public JLB_SlopeWithShapes()
Method Detail

Init

public complex Init(complex pz)
initialize the object

Overrides:
Init in class MMF_SwitchDivergentFormula
Parameters:
pz - the initial location
Returns:
initial z for iteration

Iterate

public complex Iterate(complex pz)
call for each iterated point. Overrides the parent Iterate function.

We can't use the pz value because we need to keep track of three z values. The helper function manages the pz values and bailout.

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 -
Returns:
true if bailed out.