|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectcommon:Generic
common:Formula
common:ConvergentDivergentFormula
mmf:MMF_SwitchConvergentDivergentFormula
mmf:MMF_SwitchFormulaTransformWrapper
class
A formula that wraps two transforms around any formula iteration.
With switching when used with mmf5.ufm-Generic Switch Formula
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_SwitchFormulaTransformWrapper(MMF_SwitchConvergentDivergentFormula) {
; A formula that wraps two transforms around any formula iteration.<br>
; With switching when used with mmf5.ufm-Generic Switch Formula<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_SwitchFormulaTransformWrapper(Generic pparent)
MMF_SwitchConvergentDivergentFormula.MMF_SwitchConvergentDivergentFormula(pparent)
fFormula = new @classFormula(this)
fPreTransform = new @classPreTransform(this)
fPostTransform = new @classPostTransform(this)
endfunc
func SetParams(bool f,complex v)
if @classFormula==MMF_SwitchFormula
MMF_SwitchFormula(fFormula).SetParams(f,v)
elseif @classFormula==MMF_SwitchDivergentFormula
MMF_SwitchDivergentFormula(fFormula).SetParams(f,v)
elseif @classFormula==MMF_SwitchConvergentFormula
MMF_SwitchConvergentFormula(fFormula).SetParams(f,v)
elseif @classFormula==MMF_SwitchConvergentDivergentFormula
MMF_SwitchConvergentDivergentFormula(fFormula).SetParams(f,v)
endif
endfunc
complex func Init(complex pz)
; m_Iterations = 0 not used in this formula
m_BailedOut = false
fPreTransform.Init(pz)
fPostTransform.Init(pz)
return fFormula.Init(pz)
endfunc
complex func Iterate(complex pz)
; m_Iterations = m_Iterations + 1 not used in this formula
fZold = pz
return fPostTransform.Iterate(fFormula.Iterate(fPreTransform.Iterate(pz)))
endfunc
complex func GetPrimaryExponent()
return fFormula.GetPrimaryExponent()
endfunc
bool func IsBailedOut(complex pz)
if ((@p_BailType=="Divergent" || @p_BailType=="Both" \
|| @p_BailType=="Div.+Abs.Conv.") \
&& |pz|>=@p_Bailout) \
|| ((@p_BailType=="Convergent" || @p_BailType=="Both") \
&& |pz-fZold|<=@p_SmallBail) \
|| ((@p_BailType=="Absolute Convergence" \
|| @p_BailType=="Div.+Abs.Conv.") \
&& |pz-@p_root|<=@p_SmallBail )
m_BailedOut = true
endif
return m_BailedOut
endfunc
float func GetUpperBailout()
return @p_Bailout
endfunc
float func GetLowerBailout()
return @p_SmallBail
endfunc
protected:
Formula fFormula
UserTransform fPreTransform
UserTransform fPostTransform
complex fZold
default:
title = "Switch Formula Transformations"
rating = recommended
int param v_mmfswitchformulatransformwrapper
caption = "Version (MMF_SwitchFormulaTransformWrapper)"
default = 100
hint = "This version parameter is used to detect when a change has \
been made to the formula that is incompatible with the \
previous version. When that happens, this field will reflect \
the old version number to alert you to the fact that an \
alternate rendering is being used."
visible = @v_mmfswitchformulatransformwrapper < 100
endparam
bool param p_manual
visible = false
endparam
complex param p_power
visible = false
endparam
float param p_upperbailout
visible = false
endparam
float param p_lowerbailout
visible = false
endparam
bool param p_addpixel
visible = false
endparam
heading
caption = "Bailout Options"
text = "You should note that the bailout options and values you set \
here will override the bailout settings in the 'Formula' \
parameters. This is because your chosen transforms may cause \
a divergent formula to become convergent or vice-versa."
endheading
int param p_BailType
caption = "Bailout Type"
enum = "Divergent" "Convergent" "Both" "Absolute Convergence" \
"Div.+Abs.Conv."
default = 0
hint = "If you get an empty or nearly empty fractal try switching \
from 'Divergent' to 'Convergent' or vice-versa or choosing \
'Both'. Note that in some cases if your fractal is a \
Mandelbrot you may need to ensure that the zstart value \
is non-zero."
endparam
complex param p_root
caption = "Convergence Value"
default = (1,0)
hint = "This is the value for testing for convergence to. For the \
'Magnet' formulas the value should be (1,0), if you don't \
know the value to use it's best to stick to the plain \
'Convergent' 'Bailout Type'. It's always worth trying (0,0)."
visible = @p_BailType>2
endparam
float param p_Bailout
caption = "Divergent Bailout"
default = 128.0
hint = "In general larger values will require higher iterations."
visible = @p_BailType==0 || @p_BailType==2 || @p_BailType==4
endparam
float param p_SmallBail
caption = "Convergent Bailout"
default = 1e-5
hint = "In general smaller values will require higher iterations."
visible = @p_BailType>0
endparam
heading
caption = "The Pre-Transform"
text = "Transforms z on each iteration prior to the main formula \
calculation."
endheading
UserTransform param classPreTransform
caption = "Pre-Transform"
default = NullTransform
hint = "Transforms z on each iteration prior to the main formula \
calculation. To use multiple transforms select 'Transform \
Merge' from common.ulb."
endparam
heading
caption = "The Main Formula"
endheading
heading
text = "Note that the current 'Formula' is not a switch formula \
and so will not switch using UFs built-in switch method."
visible = @classFormula!=MMF_SwitchFormula \
&& @classFormula!=MMF_SwitchDivergentFormula \
&& @classFormula!=MMF_SwitchConvergentFormula \
&& @classFormula!=MMF_SwitchConvergentDivergentFormula
endheading
Formula param classFormula
caption = "Formula"
default = MMF_SwitchStandard
hint = "The main formula."
endparam
heading
caption = "The Post-Transform"
text = "Transforms z on each iteration after the main formula \
calculation."
endheading
UserTransform param classPostTransform
caption = "Post-Transform"
default = NullTransform
hint = "Transforms z on each iteration after the main formula \
calculation. To use multiple transforms select 'Transform \
Merge' from common.ulb."
endparam
}
| Constructor Summary | |
|---|---|
MMF_SwitchFormulaTransformWrapper()
|
|
MMF_SwitchFormulaTransformWrapper(Generic pparent)
|
|
| Method Summary | |
|---|---|
float |
GetLowerBailout()
Determine the lower bailout boundary. |
complex |
GetPrimaryExponent()
Determine the primary exponent. |
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)
|
| Methods inherited from class common:Generic |
|---|
GetParent |
| Methods inherited from class Object |
|---|
|
| Constructor Detail |
|---|
public MMF_SwitchFormulaTransformWrapper(Generic pparent)
pparent - the parent, generally "this" for the parent, or zeropublic MMF_SwitchFormulaTransformWrapper()
| Method Detail |
|---|
public void SetParams(boolean f,
complex v)
SetParams in class MMF_SwitchConvergentDivergentFormulaf - flag for Mandelbrot or Julia mode, is true for Mandelbrotsv - the value to be used as the start value or 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_SwitchConvergentDivergentFormulapz - the location (normally #pixel)
public complex Iterate(complex pz)
ConvergentDivergentFormulaAs long as the sequence has not bailed out, this function will be continually called to produce sequence values.
Iterate in class ConvergentDivergentFormulapz - 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 complex GetPrimaryExponent()
FormulaMany fractals can be characterized by an exponent value that is useful to other formulas, so we provide that here. If your formula does not need or use this value, override the p_power parameter and make it hidden.
GetPrimaryExponent in class Formulapublic boolean IsBailedOut(complex pz)
ConvergentDivergentFormulaSince this is a divergent fractal, the test is easy: if it's bigger than the bailout, the sequence is done.
IsBailedOut in class ConvergentDivergentFormulapz - 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 ConvergentDivergentFormulapublic float GetLowerBailout()
ConvergentDivergentFormula
GetLowerBailout in class ConvergentDivergentFormula
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||