|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objectcommon:Generic
common:Formula
reb:Switch
reb:REB_Switch_Slope
class
A slope formula that can be used with any object formualas.
Original code modified from Damien M. Jones.
Uses a special helper class that allows TrapShape plugins for height values
class REB_Switch_Slope(reb.ulb:Switch) {
; A slope formula that can be used with any object formualas. <br>
; <p>
; Original code modified from Damien M. Jones.
; Uses a special helper class that allows TrapShape plugins for height values
public:
import "common.ulb"
; constructor
func REB_Switch_Slope(Generic pparent)
Switch.Switch(pparent)
m_mand = @p_mand
m_jul = @p_jul
m_c = @m_c
fHelper[0] = new @helperclass(this)
fHelper[1] = new @helperclass(this)
fHelper[2] = new @helperclass(this)
endfunc
; initialize the object
complex func Init(complex pz)
Switch.Init(pz)
complex z1 = fHelper[0].Init(pz) ; primary iterated point
fHelper[1].Init(pz + @offset) ; horizontally offset point
fHelper[2].Init(pz + flip(@offset)) ; vertically offset point
fIteration = 0
m_BailedOut = false
return z1
endfunc
; call for each iterated point. Overrides the parent Iterate function. <br>
; <p>
; We can't use the pz value because we need to keep track of three z values.
; The helper function manages the pz values and bailout.
complex func Iterate(complex pz)
fIteration = fIteration + 1
complex z1 = fHelper[0].Iterate()
fHelper[1].Iterate()
fHelper[2].Iterate()
m_BailedOut = fHelper[0].IsBailedOut()
if @everyiter || m_BailedOut || fIteration == #maxiter
; done, or every iteration, or last
float e1 = fHelper[0].CalcHeight(fIteration)
float e2 = fHelper[1].CalcHeight(fIteration)
float e3 = fHelper[2].CalcHeight(fIteration)
; determine surface normal
; that is, the normal to the surface defined by:
; (real(c1), imag(c1), e1)
; (real(c2), imag(c2), e2)
; (real(c3), imag(c3), e3)
float vx = e2-e1
float vy = e3-e1
float vz = -@offset
; normalize vector
float vd = 1/sqrt(sqr(vx)+sqr(vy)+sqr(vz))
vx = vx*vd
vy = vy*vd
vz = vz*vd
return vx + flip(vy); fudge z from vector
else ; didn't compute z this time
; use primary iteration value to keep periodicity working
return z1
endif
endfunc
bool func IsBailedOut(complex pz)
return m_BailedOut
endfunc
private:
REB_Switch_SlopeHelper fHelper[3]
int fIteration
default:
title = "Switch Slope"
int param v_switchslope
caption = "Version (Switch Slope)"
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_switchslope < 100
endparam
float param offset
caption = "Orbit Separation"
default = 0.00000001
exponential = true
hint = "Defines how far apart the simultaneous orbits are. Smaller \
distances will produce more accurate results."
endparam
bool param everyiter
caption = "Every Iteration"
default = false
hint = "If set, the surface normal will be computed at every \
iteration. If you are using a coloring algorithm which \
processes every iteration, you will need this."
endparam
complex param p_power ; Hide p_power from Formula
visible = false
endparam
float param p_upperbailout
caption = "Bailout value (Divergent)"
default = 1e10
min = 1.0
visible = false
endparam
float param p_lowerbailout
caption = "Bailout value"
default = 1e-10
visible = false
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
REB_Switch_SlopeHelper param helperclass
selectable = false
endparam
}
| Constructor Summary | |
|---|---|
REB_Switch_Slope()
|
|
REB_Switch_Slope(Generic pparent)
constructor |
|
| Method Summary | |
|---|---|
complex |
Init(complex pz)
initialize the object |
boolean |
IsBailedOut(complex pz)
Test whether the formula has bailed out (i.e. |
complex |
Iterate(complex pz)
call for each iterated point. |
| Methods inherited from class reb:Switch |
|---|
GetParams, SetParams |
| Methods inherited from class common:Formula |
|---|
GetLowerBailout, GetPrimaryExponent, GetUpperBailout |
| Methods inherited from class common:Generic |
|---|
GetParent |
| Methods inherited from class Object |
|---|
|
| Constructor Detail |
|---|
public REB_Switch_Slope(Generic pparent)
public REB_Switch_Slope()
| Method Detail |
|---|
public complex Init(complex pz)
Init in class Switchpz - seed value for the sequence; for a normal fractal formula, this will be #pixel
public complex Iterate(complex pz)
We can't use the pz value because we need to keep track of three z values. The helper function manages the pz values and bailout.
Iterate in class Switchpz - 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)
FormulaThis 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.
IsBailedOut in class Switchpz - 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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||