Standard
Class Standard_SlopeHelper

Object
  extended by Standard:Standard_SlopeHelper

class 
Object:Standard_SlopeHelper

Helper class for Standard_Slope.


Ultra Fractal Source

Toggle UF Source Code Display

 class Standard_SlopeHelper {
 ; Helper class for Standard_Slope.
 public:
   import "common.ulb"
 
   func Standard_SlopeHelper(Standard_Slope owner)
     fFormula = new @formulaClass(owner)
     fTransfer = new @transferClass(owner)
     if @formulaClass == DivergentFormula
       fFormulaPower = fFormula.GetPrimaryExponent()
       fFormulaBailout = fFormula.GetUpperBailout()
     else
       fFormulaPower = @power
       fFormulaBailout = @bailout
     endif
     fInvLog2 = 1/log(real(fFormulaPower))
     fPotOffset = 2 + fInvLog2 * log(log(fFormulaBailout))
   endfunc
 
   complex func Init(const complex pz)
     fZ = fFormula.Init(pz)
     fTransfer.Init(pz)
     fMinDist = 1e20
     fDistEst = 0
     fOldDistEst = 0
     fIterExp = 0
     return fZ
   endfunc
 
   complex func Iterate()
     float d
     if @zmode == "smoothed iteration"
       fOldZ = fZ
     endif
     fZ = fFormula.Iterate(fZ)
     if @zmode >= 1 && @zmode <= 5
       if (@zmode == 1); smallest |z|
         d = |fZ|; get current distance from origin
       elseif (@zmode == 2); smallest |real(z)|
         d = abs(real(fZ)); get current distances from i axis
       elseif (@zmode == 3); smallest |imag(z)|
         d = abs(imag(fZ)); get current distances from r axis
       elseif (@zmode == 4); smallest |real(z)|+|imag(z)|
         d = abs(real(fZ))+abs(imag(fZ)); get current distances from i axis
       else ; smallest |atan(z)|
         d = abs(atan2(fZ)); get current angles
       endif
       if d < fMinDist
         fMinDist = d
       endif
     elseif @zmode == "distance estimator"
       fOldDistEst = fDistEst
       ; update distance estimate
       fDistEst = fFormulaPower * fZ^(fFormulaPower-1) * fDistEst + 1
     elseif @zmode == "smoothed iteration"
       fIterExp = fIterExp + exp(-1/(cabs(fOldZ - fZ)))
     endif
     return fZ
   endfunc
   
   bool func IsBailedOut()
     return fFormula.IsBailedOut(fZ)
   endfunc
 
   float func CalcHeight(int iter)
     ; determine continuous iteration (height)
     float height
     if @zmode == "potential"
       height = iter + fPotOffset - fInvLog2*log(log(cabs(fZ)))
     elseif @zmode == "distance estimator"
       float cabsZ = cabs(fZ)
       height = sqrt(2*log(cabsZ) * cabsZ / cabs(fOldDistEst))
     elseif @zmode == "smoothed iteration"
       height = fIterExp
     else ; height based on smallest |z|
       height = fMinDist
     endif
     return fTransfer.Iterate(height)
   endfunc
 
 private:
   complex fDistEst
   Formula fFormula
   float fFormulaBailout
   complex fFormulaPower
   float fInvLog2
   float fIterExp
   float fMinDist
   complex fOldDistEst
   complex fOldZ
   float fPotOffset
   Transfer fTransfer
   complex fZ
 
 default:
   Formula param formulaClass
     caption = "Fractal Formula"
     default = Standard_Mandelbrot
     hint = "Sets the actual fractal formula to use for the lighting effect."
   endparam
   param zmode
     caption = "Height Value"
     default = 0
     enum = "potential" "smallest |z|" "smallest |real(z)|" \
            "smallest |imag(z)|" "smallest summ(z)" "smallest |atan(z)|" \
            "distance estimator" "smoothed iteration"
     hint = "Specifies what will be used to construct a height value."
   endparam
   heading
     text = "Tip: To calculate the potential correctly, the Exponent and Bail-out \
             parameters below should match those of the selected fractal \
             formula."
     visible = @zmode == 0 && @formulaClass != DivergentFormula
   endheading
   heading
     text = "Tip: To estimate the distance correctly, the Exponent parameter below \
             should match that of the selected fractal formula."
     visible = @zmode == 6 && @formulaClass != DivergentFormula
   endheading
   param power
     caption = "Exponent"
     default = (2,0)
     hint = "Overall exponent for the equation. The value (2,0) gives \
             the classic Mandelbrot type."
     visible = (@zmode == 0 || @zmode == 6) && @formulaClass != DivergentFormula
   endparam
   param bailout
     caption = "Bail-out Value"
     default = 1.0e20
     min = 0.0
     exponential = true
     hint = "This parameter defines how soon an orbit bails out while \
             iterating. Larger values give smoother outlines and better \
             coloring; values around 4 give more interesting shapes around the \
             set. Values less than 4 will distort the fractal."
     visible = @zmode == 0 && @formulaClass != DivergentFormula
   endparam
   Transfer param transferClass
     caption = "Height Transfer"
     default = Standard_HeightTransfer
     hint = "Selects a class that can transform the calculated height value."
     expanded = false
   endparam
 }
 


Constructor Summary
Standard_SlopeHelper()
           
Standard_SlopeHelper(Standard_Slope owner)
           
 
Method Summary
 float CalcHeight(int iter)
           
 complex Init(complex pz)
           
 boolean IsBailedOut()
           
 complex Iterate()
           
 
Methods inherited from class Object
 

Constructor Detail

Standard_SlopeHelper

public Standard_SlopeHelper(Standard_Slope owner)

Standard_SlopeHelper

public Standard_SlopeHelper()
Method Detail

Init

public complex Init(complex pz)

Iterate

public complex Iterate()

IsBailedOut

public boolean IsBailedOut()

CalcHeight

public float CalcHeight(int iter)