|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:Formula reb:Switch reb:REB_Switch_Embossed
class
Switchable Object version of the Embossed* formulas in Standard.ufm
Originally written by Kerry Mitchell.
class REB_Switch_Embossed(reb.ulb:Switch) { ; Switchable Object version of the Embossed* formulas in Standard.ufm ; Originally written by Kerry Mitchell. public: import "common.ulb" func REB_Switch_Embossed(Generic pparent) Switch(pparent) m_mand = @p_mand m_jul = @p_jul m_c = @m_c fHelper[0] = new @helperClass(this) fHelper[1] = new @helperClass(this) endfunc complex func Init(complex pz) Switch.Init(pz) float theta=(90-@lightangle)*pi/180.0 float size=@sizefac*0.0065/#magn dr=size*(cos(theta)+flip(sin(theta))) fHelper[0].Init(pz - dr) fHelper[1].Init(pz + dr) fIteration = 0 fRMin = 1e20 m_BailedOut = false return pz endfunc complex func Iterate(complex pz) Switch.Iterate(pz) ; We can't use the pz value because we need to keep track of two z values. fIteration = fIteration + 1 complex z1 = fHelper[0].Iterate() complex z2 = fHelper[1].Iterate() if fHelper[0].IsBailedOut() z1 = z2 ; Return second z orbit instead of first. m_BailedOut = fHelper[1].IsBailedOut() endif if m_BailedOut || fIteration == #maxiter return fHelper[0].GetResult() + flip(fHelper[1].GetResult()) else ; Return z to keep periodicity checking working. This is a trick that's ; not in the original Embossed formulas, but I borrowed it from Damien's ; Slope formulas because it's such a good idea -FS. return z1 endif endfunc bool func IsBailedOut(complex pz) return m_bailedout endfunc ; Accessor functions for the helper class. int func getIteration() return fIteration endfunc bool func updateRMin(const float r) if r < fRMin fRMin = r return true else return false endif endfunc private: REB_Switch_EmbossedHelper fHelper[2] int fIteration float fRMin default: title = "Switch Embossed" heading text = "For the best embossing effects, decrease the bailout to about 10 for \ divergent fractals, and increase the bailout to about 0.01 for \ convergent fractals." endheading param lightangle caption="Light Angle" default=120 hint="Angle of apparent light source, in degrees. With 0, the light \ comes from above. Positive values give clockwise rotation." endparam param sizefac caption="Contour Size" default=1.0 hint="Specifies the relative size of the contour bands. Larger values \ give thicker bands." exponential = true 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_EmbossedHelper param helperClass selectable = false endparam }
Constructor Summary | |
---|---|
REB_Switch_Embossed()
|
|
REB_Switch_Embossed(Generic pparent)
|
Method Summary | |
---|---|
int |
getIteration()
Accessor functions for the helper class. |
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 |
boolean |
updateRMin(float r)
|
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_Embossed(Generic pparent)
public REB_Switch_Embossed()
Method Detail |
---|
public complex Init(complex pz)
Formula
This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).
Init
in class Switch
pz
- seed value for the sequence; for a normal fractal formula, this will be #pixel
public complex Iterate(complex pz)
Formula
As long as the sequence has not bailed out, this function will be continually called to produce sequence values.
Iterate
in class Switch
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)
Formula
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.
IsBailedOut
in class Switch
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 int getIteration()
public boolean updateRMin(float r)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |