mmf
Class MMF_NovaDistanceEstimator

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

class 
DistanceEstimatorBase:MMF_NovaDistanceEstimator

Distance Estimator for the Nova formula.


Ultra Fractal Source

Toggle UF Source Code Display

 class MMF_NovaDistanceEstimator(DistanceEstimatorBase) {
 ; Distance Estimator for the Nova formula.
 public:
   import "common.ulb"
   ; @param pparent the parent, generally "this" for the parent, or zero
   func MMF_NovaDistanceEstimator(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
 ; Note that the running derivative calculation could be optimised
     if @julia
       complex fz = (@power - @relax)*pz^@power + @relax
       complex gz = @power*pz^(@power - 1.0)
       complex dfz = @power*(@power - @relax)*pz^(@power - 1.0)
       complex dgz = @power*(@power - 1.0)*pz^(@power - 2.0)
       dz = (dfz*gz - fz*dgz)/sqr(gz)
     else
       dz = 1.0
     endif
   endfunc
   ; @param pz
   func Iterate(complex pz)
 ;    m_Iterations = m_Iterations + 1
     complex fz = (@power - @relax)*pz^@power + @relax
     complex gz = @power*pz^(@power - 1.0)
     complex dfz = @power*(@power - @relax)*pz^(@power - 1.0)
     complex dgz = @power*(@power - 1.0)*pz^(@power - 2.0)
     zold = pz
     odz = dz
     dz = dz*(dfz*gz - fz*dgz)/sqr(gz)
   endfunc
   ; @param pz
   ; @return the gradient index
   float func ResultIndex(complex pz)
     float a = 0.0
     float d = 0.0
     pz = pz - zold
     dz = dz - odz
     if @modec=="Angle" || @modec=="Combined"
       if (a = atan2(pz/dz)*(0.5/#pi))<0.0
         a = a + 1.0
       endif
       if @modec=="Angle"
         return a
       endif
     endif
     if @modec=="Distance" || @modec=="Combined"
       if @fixit && @julia
         d = 0.5*cabs((@power - 1.0)*pz)
         d = -d*log(d)/cabs(dz)
       else
         d = cabs(pz/dz)
       endif
       if @modec=="Distance"
         return d
       endif
     endif
     return a+d
   endfunc
   ; @param pz
   ; @return the distance
   float func ResultDistance(complex pz)
     if @fixit && @julia
       float v = 0.5*cabs((@power - 1.0)*(pz - zold))
       return -v*log(v)/cabs(dz-odz)
     endif
     return cabs((pz-zold)/(dz-odz))
   endfunc
   ; @param pz
   ; @return the angle (from 0 to 1)
   float func ResultAngle(complex pz)
     float r = 0.0
     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 Nova Distance Estimator"
   int param v_mmf_novadistanceestimator
     caption = "Version (MMF Nova 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
   heading
     text = "Note that this colouring is only based on distance estimation, \
             it's not really accurate at true distance estimation."
   endheading
   bool param julia
     caption = "Julia ?"
     default = false
     hint = "Enable when the main formula is a Julia."
   endparam
   bool param fixit
     caption = "Fix Julias ?"
     default = false
     hint = "When enabled the DE is better for some Julia Sets."
     visible = @julia
   endparam
   int param modec
     caption = "Mode"
     enum = "Distance" "Angle" "Combined"
     default = 0
   endparam
   complex param power
     caption = "Nova Power"
     default = (3,0)
     hint = "This should match the power in the main formula."
   endparam
   complex param relax
     caption = "Relaxation"
     default = (1,0)
     hint = "This should match the relaxation in the main formula."
   endparam
 }
 


Constructor Summary
MMF_NovaDistanceEstimator()
           
MMF_NovaDistanceEstimator(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_NovaDistanceEstimator

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

MMF_NovaDistanceEstimator

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