|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:Formula reb:REB_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_Slope(common.ulb:Formula) { ; 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_Slope(Generic pparent) Formula.Formula(pparent) fHelper[0] = new @helperclass(this) fHelper[1] = new @helperclass(this) fHelper[2] = new @helperclass(this) endfunc ; initialize the object complex func Init(complex pz) Formula.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 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 private: REB_SlopeHelper fHelper[3] int fIteration default: title = "Slope with Shapes" int param v_slopewithshapes caption = "Version (Slope With Shapes)" default = 101 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_slopewithshapes < 101 endparam heading text = "Formulas that contain \ the word 'Switch' should not be used here. For those formulas use the 'Switch \ Slope' plugin together with 'Object Formula Switch Lite'." endheading REB_SlopeHelper param helperclass selectable = false 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 }
Constructor Summary | |
---|---|
REB_Slope()
|
|
REB_Slope(Generic pparent)
constructor |
Method Summary | |
---|---|
complex |
Init(complex pz)
initialize the object |
complex |
Iterate(complex pz)
call for each iterated point. |
Methods inherited from class common:Formula |
---|
GetLowerBailout, GetPrimaryExponent, GetUpperBailout, IsBailedOut |
Methods inherited from class common:Generic |
---|
GetParent |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public REB_Slope(Generic pparent)
public REB_Slope()
Method Detail |
---|
public complex Init(complex pz)
Init
in class Formula
pz
- 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 Formula
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |