mmf Class MMF_SwitchTransformFormula

Object common:Generic common:Formula mmf:MMF_SwitchFormula mmf:MMF_SwitchTransformFormula

class
MMF_SwitchFormula:MMF_SwitchTransformFormula

Any Transform applied as a formula.

Ultra Fractal Source
class MMF_SwitchTransformFormula(MMF_SwitchFormula) {
; Any Transform applied as a formula.<br>
public:
import "common.ulb"

; @param pparent the parent, generally "this" for the parent, or zero
func MMF_SwitchTransformFormula(Generic pparent)
MMF_SwitchFormula.MMF_SwitchFormula(pparent)
fTransform = new @classTransform(this)
endfunc

complex func Init(complex pz)
;    m_Iterations = 0 not used in this formula
m_BailedOut = false
if @p_initold=="Fixed Value"
fZold = @p_zold
elseif @p_initold=="Position"
fZold = pz
elseif @p_initold=="Start Value"
if fType
fZold = fValue + pz
else
fZold = fValue
endif
else
fZold = pz
endif
else;if @p_initold=="Constant"
if fType
fZold = pz
else
fZold = fConstant
endif
endif
fTransform.Init(pz)
if fType
fConstant = pz
return fValue + fConstant
else
return fValue
endif
else
return pz
endif
endfunc

complex func Iterate(complex pz)
;    m_Iterations = m_Iterations + 1 not used in this formula
complex zz = fTransform.Iterate(pz)
if @p_type=="tx(z)+c"
zz = zz + fConstant
elseif @p_type=="c*tx(z)"
return fConstant*zz
elseif @p_type=="tx(z)+zold+c"
zz = zz + fZold + fConstant
elseif @p_type=="c*tx(z)+zold"
zz = fConstant*zz + fZold
elseif @p_type=="zold*tx(z)+c"
zz = fZold*zz + fConstant
else;if @p_type=="c*zold*tx(z)"
zz = fConstant*fZold*zz
endif
fZold = pz
return zz
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:
UserTransform fTransform
complex fZold

default:
title = "Switch Transform Formula"
rating = recommended
int param v_mmfswitchtransformformula
caption = "Version (MMF_SwitchTransformFormula)"
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_mmfswitchtransformformula < 100
endparam
complex param p_power
visible = false
endparam
caption = "Offset z start"
default = false
hint = "When enabled the z start value (in Mandelbrot mode) is offset \
by the constant for the current position - normally '#pixel'."
visible = !@p_manual || @p_mandy
endparam
caption = "Bailout Options"
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
caption = "The Formula method"
int param p_type
caption = "Fractal Type"
enum = "tx(z)+c" "c*tx(z)" "tx(z)+zold+c" "c*tx(z)+zold" \
"zold*tx(z)+c" "c*zold*tx(z)"
default = 0
endparam
int param p_initold
caption = "Initial Zold"
enum = "Fixed Value" "Position" "Start Value" "Constant"
default = 0
endparam
complex param p_zold
caption = "Initial Zold Value"
default = (0,0)
visible = @p_initold==0
endparam
caption = "The Formula Transform"
text = "Transforms z on each iteration."
UserTransform param classTransform
caption = "The Transform"
default = MMF_PowerFunctions
hint = "Transforms z on each iteration. To use multiple \
transforms select 'Transform Merge' from common.ulb."
endparam
}

Constructor Summary
MMF_SwitchTransformFormula()

MMF_SwitchTransformFormula(Generic pparent)

Method Summary
float GetLowerBailout()
Determine the lower bailout boundary.
float GetUpperBailout()
Determine the upper bailout boundary.
complex Init(complex pz)
Set up for a sequence of values
boolean IsBailedOut(complex pz)
Test whether the formula has bailed out (i.e.
complex Iterate(complex pz)
Produce the next value in the sequence

Methods inherited from class mmf:MMF_SwitchFormula
SetParams

Methods inherited from class common:Formula
GetPrimaryExponent

Methods inherited from class common:Generic
GetParent

Methods inherited from class Object

Constructor Detail

MMF_SwitchTransformFormula

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

MMF_SwitchTransformFormula

public MMF_SwitchTransformFormula()
Method Detail

Init

public complex Init(complex pz)
Description copied from class: Formula
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 Formula
Parameters:
pz - seed value for the sequence; for a normal fractal formula, this will be #pixel
Returns:
first value in the sequence; this corresponds to #z in a fractal formula

Iterate

public complex Iterate(complex pz)
Description copied from class: Formula
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 Formula
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: Formula
Test whether the formula has bailed out (i.e. the sequence is complete)

This is typically called once per iteration to test whether the sequence has completed. If producing this result is difficult to do separately from the Iterate() processing, you should produce the result in Iterate() and set the m_BailedOut flag appropriately, and leave IsBailedOut() unimplemented in your class to inherit this behavior.

Note that this test is the OPPOSITE sense of the bailout: section in UF's fractal formulas. A bailout: section returns TRUE to continue iterating. IsBailedOut() must return FALSE to continue iterating.

Overrides:
IsBailedOut in class Formula
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: Formula
Determine the upper bailout boundary.

By default, we return a simple fixed value. Divergent formulas will override this function and return the real parameter.

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

GetLowerBailout

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

By default, we return a simple fixed value. Convergent formulas will override this function and return the real parameter.

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