reb
Class REB_Switch_SlopeHelper

Object
  extended by reb:REB_Switch_SlopeHelper

class 
Object:REB_Switch_SlopeHelper

Helper class for REB_Slope.

Makes possible the use of any object formula with REB_Slope. Works for both convergent and divergent formulas. Manages height values as trap shapes.


Ultra Fractal Source

Toggle UF Source Code Display

 class REB_Switch_SlopeHelper {
 ; Helper class for REB_Slope. <br>
 ; <p>
 ; Makes possible the use of any object formula with REB_Slope. Works for both
 ; convergent and divergent formulas. Manages height values as trap shapes.
 public:
   import "common.ulb"
   import "Standard.ulb"
 
   ; constructor
   func REB_Switch_SlopeHelper(REB_Switch_Slope owner)
     fOwner = owner
     fFormula = new @formulaclass(owner)
     fFormula2 = new @formulaclass2(owner)
     fTransfer = new @transferclass(owner)
     fheight = new @heightvalue(owner)
     fTransform = new @transform(owner)
     fTransform2 = new @transform2(owner)
   endfunc
 
   ; initialize the object
   complex func Init(const complex pz)
     fOwner.Getparams(m_mand, m_jul, m_c)
     fFormula.SetParams(m_mand, m_jul, m_c)
     fZ = fFormula.Init(pz)
     if @dual
       fFormula2.SetParams(m_mand, m_jul, m_c)
       fFormula2.Init(pz)
     endif
     fTransform.init(fZ)
     fTransform2.init(fZ)
     fTransfer.Init(pz)
     fheight.Init(pz)
     fMinDist = 1e20
     m_sflag = false
     fIterz = 0
     m_zold = 0
     m_iter = 0
     return fZ
   endfunc
 
   ; call for each iterated point
   complex func Iterate()
     m_zold = fZ
     if (m_iter >= @prestart && m_iter < (@prestart+@preend))&& @transform \
        != NullTransform
       fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength)
     endif
     fZ = fFormula.Iterate(fZ)
     if @dual
       fZ = fFormula2.iterate(fZ)
     endif
     if (m_iter >= @poststart && m_iter < (@poststart+@postend))&& @transform2 \
        != NullTransform
       fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2)
     endif
     m_iter = m_iter + 1
 
     float d = fheight.Iterate(fZ)
     if d == -10000
       m_sflag = true
     endif
     if @tx
       d = cabs(fheight.GetTransformedPoint())
     endif
     if d < fMinDist && !m_sflag
       fMinDist = d
     endif
     if m_sflag
       fIterz = fIterz + exp(-cabs(fZ)-0.5/(cabs(m_zold - fZ)))
     endif
     return fZ
   endfunc
 
   bool func IsBailedOut()
     return fFormula.IsBailedOut(fZ)
   endfunc
 
     ; determine continuous iteration (height)
   float func CalcHeight(int iter)
     float height = fMinDist
     if m_sflag
       height = fIterz
     endif
     return fTransfer.Iterate(height)
   endfunc
 
 private:
   Switch fFormula
   Switch fFormula2
   UserTransform fTransform
   UserTransform fTransform2
   float fMinDist
   Transfer fTransfer
   complex fZ
   TrapShape fheight
   bool m_sflag
   complex m_zold
   float fIterz
   int m_iter
   REB_Switch_Slope fOwner
   bool m_mand
   bool m_jul
   complex m_c
   
 default:
   int param v_switchslopehelper
     caption = "Version (REB Switch Slope Helper)"
     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_switchslopehelper < 100
   endparam
   UserTransform param transform
     caption = "Pre transform"
     default = NullTransform
     expanded = false
   endparam
   int param prestart
     caption = "Start Iter (Pre)"
     default = 0
     visible = @transform != NullTransform
   endparam
   int param preend
     caption = "Iterations (Pre)"
     default = 1
     visible = @transform != NullTransform
   endparam
   float param strength
     caption = "Strength (Pre)"
     default = 1
     visible = @transform != NullTransform
   endparam
   bool param dual
     caption = "Use dual formulas"
     default = false
   endparam
   Switch param formulaClass
     caption = "Fractal Formula"
     default = REB_MandelbrotJulia_switch
   endparam
   Switch param formulaClass2
     caption = "Fractal Formula"
     default = REB_Ikenaga_Switch
     visible = @dual
   endparam
   UserTransform param transform2
     caption = "Post transform"
     default = NullTransform
     expanded = false
   endparam
   int param poststart
     caption = "Start Iter (Post)"
     default = 0
     visible = @transform2 != NullTransform
   endparam
   int param postend
     caption = "Iterations (Post)"
     default = 1
     visible = @transform2 != NullTransform
   endparam
   float param strength2
     caption = "Strength (Post)"
     default = 1
     visible = @transform2 != NullTransform
   endparam
   TrapShape param heightvalue
     caption = "Height value"
     default = REB_TrapShapeSlopeBasic
   endparam
   Transfer param transferclass
     caption = "Height Transfer"
     default = Standard_HeightTransfer
     hint = "Selects a class that can transform the calculated height value."
     expanded = false
   endparam
   bool param tx
     caption = "Use transformed value"
     default = false
     visible = @heightvalue !=  REB_TrapShapeSlopeBasic
   endparam
 }
 


Constructor Summary
REB_Switch_SlopeHelper()
           
REB_Switch_SlopeHelper(REB_Switch_Slope owner)
          constructor
 
Method Summary
 float CalcHeight(int iter)
          determine continuous iteration (height)
 complex Init(complex pz)
          initialize the object
 boolean IsBailedOut()
           
 complex Iterate()
          call for each iterated point
 
Methods inherited from class Object
 

Constructor Detail

REB_Switch_SlopeHelper

public REB_Switch_SlopeHelper(REB_Switch_Slope owner)
constructor


REB_Switch_SlopeHelper

public REB_Switch_SlopeHelper()
Method Detail

Init

public complex Init(complex pz)
initialize the object


Iterate

public complex Iterate()
call for each iterated point


IsBailedOut

public boolean IsBailedOut()

CalcHeight

public float CalcHeight(int iter)
determine continuous iteration (height)