mmf
Class MMF_StandardDistanceEstimator

Object
  extended by common:Generic
      extended by common:Coloring
          extended by common:GradientColoring
              extended by mmf:DistanceEstimatorBase
                  extended by mmf:MMF_StandardDistanceEstimator

class 
DistanceEstimatorBase:MMF_StandardDistanceEstimator

Distance Estimator for formulas of the form z^p+c.


Ultra Fractal Source

Toggle UF Source Code Display

 class MMF_StandardDistanceEstimator(DistanceEstimatorBase) {
 ; Distance Estimator for formulas of the form z^p+c.
 public:
   import "common.ulb"
   ; @param pparent the parent, generally "this" for the parent, or zero
   func MMF_StandardDistanceEstimator(Generic pparent)
     DistanceEstimatorBase.DistanceEstimatorBase(pparent)
   endfunc
   ; @param pz
   ; @param ppixel
   func Init(complex pz, complex ppixel)
     DistanceEstimatorBase.Init(pz, ppixel)
     sz = dz = 1.0
     if @julia && @mode=="Angle"
       sz = @power*pz^(@power - 1)
       m_Iterations = 1
     endif
   endfunc
   ; @param pz
   func Iterate(complex pz)
     if !@julia && m_Iterations==0
       sz = @power*pz^(@power - 1)
     elseif @julia || m_Iterations>0
       dz = @power*dz*pz^(@power - 1)
     endif
     m_Iterations = m_Iterations + 1
   endfunc
   ; @param pz
   ; @return the gradient index
   float func ResultIndex(complex pz)
     float a = 0.0
     float d = 0.0
     if @mode=="Angle" || @mode=="Combined"
       if (a = atan2(pz/(dz*sz))*(0.5/#pi))<0.0
         a = a + 1.0
       endif
       if @mode=="Angle"
         return a
       endif
     endif
     if @mode=="Distance" || @mode=="Combined"
       d = cabs(pz)
       d = cabs((@power*log(d)*d/cabs(dz))^(1.0/@power))
       if @mode=="Distance"
         return d
       endif
     endif
     return a+d
   endfunc
   ; @param pz
   ; @return the distance
   float func ResultDistance(complex pz)
     d = cabs(pz)
     return cabs((@power*log(d)*d/cabs(dz))^(1.0/@power))
   endfunc
   ; @param pz
   ; @return the angle (from 0 to 1)
   float func ResultAngle(complex pz)
     float r
     if (r=atan2(pz/(dz*sz))*(0.5/#pi))<0.0
       r = r + 1.0
     endif
     return r
   endfunc
 
 protected:
   complex sz
 
 default:
   title = "MMF Standard Distance Estimator"
   int param v_mmf_standarddistanceestimator
     caption = "Version (MMF Standard Distance Estimator)"
     enum = "1.0"
     default = 0
     hint = "This field is to absolutely ensure backward compatibility, \
             the default will always be set to the latest version, but \
             there may be some cases where an older effect that you like \
             is lost in an update and you could still use it by selecting \
             the older version number."
     visible = false
   endparam
   bool param julia
     caption = "Julia ?"
     default = false
     hint = "Enable if your main formula is a Julia."
   endparam
   int param mode
     caption = "Mode"
     enum = "Distance" "Angle" "Combined"
     default = 0
   endparam
   complex param power
     caption = "Power (p in z^p+c)"
     default = (2,0)
   endparam
 }
 


Constructor Summary
MMF_StandardDistanceEstimator()
           
MMF_StandardDistanceEstimator(Generic pparent)
           
 
Method Summary
 void Init(complex pz, complex ppixel)
          Set up for a sequence of values
 void Iterate(complex pz)
          Process the next value in the sequence
 float ResultAngle(complex pz)
           
 float ResultDistance(complex pz)
           
 float ResultIndex(complex pz)
          Produce a resulting color index after a sequence is finished
 
Methods inherited from class common:GradientColoring
IsGradient, IsSolid, Result
 
Methods inherited from class common:Coloring
GetPixel
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

MMF_StandardDistanceEstimator

public MMF_StandardDistanceEstimator(Generic pparent)
Parameters:
pparent - the parent, generally "this" for the parent, or zero

MMF_StandardDistanceEstimator

public MMF_StandardDistanceEstimator()
Method Detail

Init

public void Init(complex pz,
                 complex ppixel)
Description copied from class: GradientColoring
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 GradientColoring
Parameters:
pz -
ppixel -

Iterate

public void Iterate(complex pz)
Description copied from class: GradientColoring
Process 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. Note that such processing generally will not know in advance precisely how long the sequence is, and should be prepared to deal with sequences of arbitrary length.

Your coloring may determine at some point that a solid color should be used rather than an index value.

Overrides:
Iterate in class GradientColoring
Parameters:
pz -

ResultIndex

public float ResultIndex(complex pz)
Description copied from class: GradientColoring
Produce a resulting color index after a sequence is finished

This corresponds to the final: section in a coloring formula. Once it is called, no further calls to Iterate() should be made without calling Init() first.

Overrides:
ResultIndex in class GradientColoring
Parameters:
pz -
Returns:
the gradient index

ResultDistance

public float ResultDistance(complex pz)
Overrides:
ResultDistance in class DistanceEstimatorBase
Parameters:
pz -
Returns:
the distance

ResultAngle

public float ResultAngle(complex pz)
Overrides:
ResultAngle in class DistanceEstimatorBase
Parameters:
pz -
Returns:
the angle (from 0 to 1)