mmf
Class MMF_NewtonDistanceEstimator

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

class 
DistanceEstimatorBase:MMF_NewtonDistanceEstimator

Distance Estimator for Newton formulas solving z^p-c.


Ultra Fractal Source

Toggle UF Source Code Display

 class MMF_NewtonDistanceEstimator(DistanceEstimatorBase) {
 ; Distance Estimator for Newton formulas solving z^p-c.
 public:
   import "common.ulb"
   ; @param pparent the parent, generally "this" for the parent, or zero
   func MMF_NewtonDistanceEstimator(Generic pparent)
     DistanceEstimatorBase.DistanceEstimatorBase(pparent)
   endfunc
   ; @param pz
   ; @param ppixel
   func Init(complex pz, complex ppixel)
     DistanceEstimatorBase.Init(pz, ppixel)
     zold = pz
     odz = 1.0
     dz = (@power - 1.0)/@power - @root*(@power - 1.0)*pz^(@power - 2.0) \
                                  /(@power*pz^(2.0*(@power - 1.0)))
   endfunc
   ; @param pz
   func Iterate(complex pz)
 ;    m_Iterations = m_Iterations + 1
     zold = pz
     odz = dz
     dz = dz *((@power - 1.0)/@power - @root*(@power - 1.0)*pz^(@power - 2.0) \
                                      /(@power*pz^(2.0*(@power - 1.0))))
   endfunc
   ; @param pz
   ; @return the gradient index
   float func ResultIndex(complex pz)
     float a = 0.0
     float d = 0.0
     complex zv = pz - zold
     complex dzv = 1.0/(dz - odz)
     if @mode=="Angle" || @mode=="Combined"
       if (a = atan2(zv*dzv)*(0.5/#pi))<0.0
         a = a + 1.0
       endif
       if @mode=="Angle"
         return a
       endif
     endif
     if @mode=="Distance" || @mode=="Combined"
       d = 0.5*cabs((@power - 1.0)*zv)
       d = -d*log(d)*cabs(dzv)
       if @mode=="Distance"
         return d
       endif
     endif
     return a+d
   endfunc
   ; @param pz
   ; @return the distance
   float func ResultDistance(complex pz)
     float v = 0.5*cabs((@power - 1.0)*(pz - zold))
     return -v*log(v)/cabs(dz-odz)
   endfunc
   ; @param pz
   ; @return the angle (from 0 to 1)
   float func ResultAngle(complex pz)
     float r
     if (r=atan2((pz-zold)/(dz-odz))*(0.5/#pi))<0.0
       r = r + 1.0
     endif
     return r
   endfunc
 
 protected:
   complex zold
   complex odz
 
 default:
   title = "MMF Newton Distance Estimator"
   int param v_mmf_newtondistanceestimator
     caption = "Version (MMF Newton 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
   int param mode
     caption = "Mode"
     enum = "Distance" "Angle" "Combined"
     default = 0
   endparam
   complex param power
     caption = "Power (p in z^p-r)"
     default = (3,0)
   endparam
   complex param root
     caption = "Root (r in z^p-r)"
     default = (1,0)
   endparam
 }
 


Constructor Summary
MMF_NewtonDistanceEstimator()
           
MMF_NewtonDistanceEstimator(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_NewtonDistanceEstimator

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

MMF_NewtonDistanceEstimator

public MMF_NewtonDistanceEstimator()
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)