reb
Class REB_SJMagnet2_Switch
Object
common:Generic
common:Formula
reb:Switch
reb:REB_SJMagnet2_Switch
class
- Switch:REB_SJMagnet2_Switch
Ultra Fractal Source
Toggle UF Source Code Display
class REB_SJMagnet2_Switch(Switch) {
public:
import "common.ulb"
; constructor
func REB_SJMagnet2_Switch(Generic pparent)
Switch.Switch(pparent)
m_power = @p_power
m_mand = @p_mand
m_jul = @p_jul
m_bailout = @p_upperbailout
m_bailout2 = @p_lowerbailout
m_c = @m_c
m_test = @test
endfunc
; initialize the formula
complex func Init(complex pz)
Switch.Init(pz)
complex z2 = pz
if m_mand
pz = 0
m_c=@p2+@p1*real(z2)+flip(imag(z2))
bval = 1
endif
if m_jul
pz=real(z2)+flip(imag(z2)*@p1)
m_c=@p2+@p1*real(m_c)+flip(imag(m_c))
endif
return pz
endfunc
; call for each iterated point
complex func Iterate(complex pz)
Switch.Iterate(pz)
if m_jul
bval = m_zold
endif
return sqr( (pz^3 + 3*(m_c-1)*pz + (m_c-1)*(m_c-2)) / \
(3*pz^2 + 3*(m_c-2)*pz + (m_c-1)*(m_c-2) + 1) )
endfunc
; Override the default function for bailout
bool func IsBailedOut(complex pz)
return |pz-bval| < m_bailout2 || |pz| > m_bailout
endfunc
private:
complex bval
default:
title = "SJMagnet 2 Switch"
int param v_SJMagnet2switch
caption = "Version (SJMagnet 2 Switch)"
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_SJMagnet2switch < 100
endparam
heading
text = "Most Mandelbrot-type formulas initialize in the z plane and iterate \
in the c plane. Gordon Lamb proposed a geometry which involves iteration \
in the zc plane (type SJ) or in the cz plane (type 3RDIM). A 'Plane \
hybridization' value of zero gives pure zc or cz iteration, while a \
'Plane hybridization' value of one gives the classical c plane iteration. \
Intermediate values can produce very interesting results."
endheading
float param p1
caption = "Plane hybridization"
default = 0.5
min = 0
max = 1
endparam
param p2
caption = "Iteration Plane position"
default = (0.0,0.0)
endparam
bool param p_mand
caption = "Mandel Type"
default = true
visible = false
endparam
bool param p_jul
caption = "Julia Type"
default = false
visible = false
endparam
complex param m_c
caption = "Julia Seed"
default = (0,0)
visible = false
endparam
param test
caption = "Bailout Test"
default = 0
enum = "mod" "real" "imag" "or" "and" "manh" "manr"
hint = "mod is the standard bailout. The remaining bailout methods are \
from Fractint."
endparam
float param p_upperbailout
caption = "Bailout value (Divergent)"
default = 1e10
min = 1.0
endparam
float param p_lowerbailout
caption = "Bailout value"
default = 1e-10
visible = false
endparam
complex param p_power ; Overrides p_power from Formula
caption = "Power"
default = (2,0)
visible = false
endparam
}
Methods inherited from class Object |
|
REB_SJMagnet2_Switch
public REB_SJMagnet2_Switch(Generic pparent)
- constructor
REB_SJMagnet2_Switch
public REB_SJMagnet2_Switch()
Init
public complex Init(complex pz)
- initialize the formula
- Overrides:
Init
in class Switch
- 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)
- call for each iterated point
- Overrides:
Iterate
in class Switch
- 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)
- Override the default function for bailout
- Overrides:
IsBailedOut
in class Switch
- 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)