mmf
Class MMF_SwitchNova

Object
  extended by common:Generic
      extended by common:Formula
          extended by common:ConvergentDivergentFormula
              extended by mmf:MMF_SwitchConvergentDivergentFormula
                  extended by mmf:MMF_SwitchNova

class 
MMF_SwitchConvergentDivergentFormula:MMF_SwitchNova

Object version of NovaMandel for switching
Nova fractal (Mandelbrot form), a modified Newtonian-style fractal.
Object switch version by David Makin
Originators Damien M. Jones, Paul Derbyshire

Note that for historical reasons this formula uses its own zold and bailout values instead of those defined in the base class doing so should not be taken as a model for other formulas.


Ultra Fractal Source

Toggle UF Source Code Display

 class MMF_SwitchNova(MMF_SwitchConvergentDivergentFormula) {
 ;
 ; Object version of NovaMandel for switching<br>
 ;
 ; Nova fractal (Mandelbrot form), a modified Newtonian-style fractal.<br>
 ; Object switch version by David Makin<br>
 ;
 ; Originators Damien M. Jones, Paul Derbyshire<p>
 ;
 ; Note that for historical reasons this formula uses its own
 ; zold and bailout values instead of those defined in the base class
 ; doing so should not be taken as a model for other formulas.<br>
 public:
   import "common.ulb"
   ; @param pparent the parent, generally "this" for the parent, or zero
   func MMF_SwitchNova(Generic pparent)
     MMF_SwitchConvergentDivergentFormula.MMF_SwitchConvergentDivergentFormula(pparent)
   endfunc
 
   ; Note that here if the formula is in Mandelbrot mode then one is added
   ; to the start value by default.
   ; @param f flag, true for Mandelbrot mode, false for Julia mode
   ; @param v either the start value or the constant  
   func SetParams(bool f,complex v)
     if !@p_manual
       if (fType = f)
         fValue = fConstant = v + 1.0
       else
         fValue = fConstant = v
       endif
     endif
   endfunc
 
   complex func Init(complex pz)
     complex zz = MMF_SwitchConvergentDivergentFormula.Init(pz)
     if @p_advanced && @p_switch=="Exponent"
       pm1 = fConstant - 1.0
     endif
     return zz
   endfunc
 
   complex func Iterate(complex pz)
     MMF_SwitchConvergentDivergentFormula.Iterate(pz)
     if !@p_advanced || @p_switch=="Normal"
       if @p_power == (3, 0)  ; special optimized routine for power 3
         complex zsquared = sqr(pz)
         return pz - @relax * (zsquared*pz-1.0) / (3.0*zsquared) + fConstant
       else
         return pz - @relax * (pz^@p_power-1.0) \
                / (@p_power * pz^(@p_power-1.0)) + fConstant
       endif
     elseif @p_switch=="Exponent"
       return pz - @relax * (pz^fConstant-1.0) \
              / (fConstant * pz^pm1) + @p_seed1
     else;if @p_switch=="Relaxation"
       return pz - fConstant * (pz^@p_power-1.0) \
              / (@p_power * pz^(@p_power-1.0)) + @p_seed1
     endif
   endfunc
 
   bool func IsBailedOut(complex pz)
     if ((@p_BailType=="Divergent" || @p_BailType=="Both") \
         && |pz|>@p_bailout1) \
        || ((@p_BailType=="Convergent" || @p_BailType=="Both") \
            && |pz-m_ZOld|<@p_bailout)
       m_BailedOut = true
     endif
     return m_BailedOut
   endfunc
 
   float func GetUpperBailout()
     return @p_bailout1
   endfunc
 
   float func GetLowerBailout()
     return @p_bailout
   endfunc
 
 private:
   complex pm1
 
 default:
   title = "Switch Nova"
   rating = recommended
   float param p_lowerbailout
     visible = false
   endparam
   float param p_upperbailout
     visible = false
   endparam
   complex param p_start
     caption = "Mandelbrot Start Value"
     default = (1,0)
     visible = @p_manual && @p_mandy
   endparam
   complex param p_seed
     caption = "Julia Seed"
     default = (0,0)
     visible = @p_manual && !@p_mandy
   endparam
   heading
     caption = "Information"
     text = "It should be noted that when using the Mandelbrot Start \
             Value from a parent switching formula 1 is added to the \
             value since generally the parental default will be (0,0) \
             and the standard start value for Nova is (1,0)."
   endheading
   heading
     enabled = false
   endheading
   bool param p_advanced
     caption = "Enable Advanced Settings"
     default = false
     hint = "When enabled you can choose which variable is switchable."
   endparam
   int param p_switch
     caption = "Switch Value"
     enum = "Normal" "Exponent" "Relaxation"
     default = 2
     hint = "In 'Normal' mode the additive constant is the switchable \
             variable, in the other modes the relevant values are made \
             switchable instead."
     visible = @p_advanced
   endparam
   complex param p_seed1
     caption = "Seed"
     default = (-0.4,0.425)
     hint = "The additive constant."
     visible = @p_advanced && @p_switch>0
   endparam
   complex param p_power
     caption = "Exponent"
     default = (3,0)
     hint = "Overall exponent for the equation. The value (3,0) gives \
             the classic Nova fractals."
     visible = !@p_advanced || @p_switch!=1
   endparam
   complex param relax
     caption = "Relaxation"
     default = (1,0)
     hint = "This can be used to slow down the convergence of \
             the formula."
     visible = !@p_advanced || @p_switch!=2
   endparam
   int param p_BailType
     caption = "Bailout Type"
     enum = "Divergent" "Convergent" "Both"
     default = 1
   endparam
   float param p_bailout
     caption = "Convergent Bailout"
     default = 0.00001
     exponential = true
     hint = "Convergent bailout value; smaller values will cause more \
             iterations to be done for each point."
     visible = @p_BailType>0
   endparam
   float param p_bailout1
     caption = "Divergent Bailout"
     default = 1e20
     exponential = true
     hint = "Divergent bailout value; it's best to use large values to \
             avoid erroneous detection of divergent bailout in convergent \
             areas."
     visible = @p_BailType!=1
   endparam
 }
 


Constructor Summary
MMF_SwitchNova()
           
MMF_SwitchNova(Generic pparent)
           
 
Method Summary
 float GetLowerBailout()
          Determine the lower bailout boundary.
 float GetUpperBailout()
          Determine the upper bailout boundary.
 complex Init(complex pz)
          Note that here zold is initialised to initial z
 boolean IsBailedOut(complex pz)
          Test whether the formula has bailed out (i.e.
 complex Iterate(complex pz)
          Produce the next value in the sequence
 void SetParams(boolean f, complex v)
          Note that here if the formula is in Mandelbrot mode then one is added to the start value by default.
 
Methods inherited from class common:Formula
GetPrimaryExponent
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

MMF_SwitchNova

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

MMF_SwitchNova

public MMF_SwitchNova()
Method Detail

SetParams

public void SetParams(boolean f,
                      complex v)
Note that here if the formula is in Mandelbrot mode then one is added to the start value by default.

Overrides:
SetParams in class MMF_SwitchConvergentDivergentFormula
Parameters:
f - flag, true for Mandelbrot mode, false for Julia mode
v - either the start value or the constant

Init

public complex Init(complex pz)
Description copied from class: MMF_SwitchConvergentDivergentFormula
Note that here zold is initialised to initial z

What it's initialised to is normally irrelevant unless the derived formula uses zold in its main calculations in which case the user should be given the choice of initialising zold to either the location, the initial z value or a fixed constant.

Overrides:
Init in class MMF_SwitchConvergentDivergentFormula
Parameters:
pz - the location (normally #pixel)
Returns:
initial z for iteration

Iterate

public complex Iterate(complex pz)
Description copied from class: ConvergentDivergentFormula
Produce 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.

Overrides:
Iterate in class ConvergentDivergentFormula
Parameters:
pz - previous value in the sequence; corresponds to #z in a fractal formula. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call.
Returns:
the next value in the sequence

IsBailedOut

public boolean IsBailedOut(complex pz)
Description copied from class: ConvergentDivergentFormula
Test whether the formula has bailed out (i.e. the sequence is complete)

Since this is a divergent fractal, the test is easy: if it's bigger than the bailout, the sequence is done.

Overrides:
IsBailedOut in class ConvergentDivergentFormula
Parameters:
pz - last sequence value to test; this should be the value returned from the previous Iterate() call. Note that it is acceptable to ignore pz and use m_BailedOut, but any code calling IsBailedOut() should pass in the correct pz for Formula classes which do not use m_BailedOut.
Returns:
true if the sequence has bailed out (i.e. should be terminated)

GetUpperBailout

public float GetUpperBailout()
Description copied from class: ConvergentDivergentFormula
Determine the upper bailout boundary.

Overrides:
GetUpperBailout in class ConvergentDivergentFormula
Returns:
the upper bailout parameter

GetLowerBailout

public float GetLowerBailout()
Description copied from class: ConvergentDivergentFormula
Determine the lower bailout boundary.

Overrides:
GetLowerBailout in class ConvergentDivergentFormula
Returns:
the lower bailout parameter