|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:Formula common:ConvergentDivergentFormula mmf:MMF_SwitchConvergentDivergentFormula mmf:MMF_SwitchNova
class
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.
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 |
---|
public MMF_SwitchNova(Generic pparent)
pparent
- the parent, generally "this" for the parent, or zeropublic MMF_SwitchNova()
Method Detail |
---|
public void SetParams(boolean f, complex v)
SetParams
in class MMF_SwitchConvergentDivergentFormula
f
- flag, true for Mandelbrot mode, false for Julia modev
- either the start value or the constantpublic complex Init(complex pz)
MMF_SwitchConvergentDivergentFormula
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.
Init
in class MMF_SwitchConvergentDivergentFormula
pz
- the location (normally #pixel)
public complex Iterate(complex pz)
ConvergentDivergentFormula
As long as the sequence has not bailed out, this function will be continually called to produce sequence values.
Iterate
in class ConvergentDivergentFormula
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.
public boolean IsBailedOut(complex pz)
ConvergentDivergentFormula
Since this is a divergent fractal, the test is easy: if it's bigger than the bailout, the sequence is done.
IsBailedOut
in class ConvergentDivergentFormula
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.
public float GetUpperBailout()
ConvergentDivergentFormula
GetUpperBailout
in class ConvergentDivergentFormula
public float GetLowerBailout()
ConvergentDivergentFormula
GetLowerBailout
in class ConvergentDivergentFormula
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |