|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object reb:REB_SlopeHelper
class
Helper class for REB_Slope.
Makes possible the use of any object formula with REB_Slope. Works for both
convergent and divergent formulas. Manages height values as trap shapes.
class REB_SlopeHelper { ; Helper class for REB_Slope. <br> ; <p> ; Makes possible the use of any object formula with REB_Slope. Works for both ; convergent and divergent formulas. Manages height values as trap shapes. public: import "common.ulb" import "Standard.ulb" ; constructor func REB_SlopeHelper(REB_Slope owner) fFormula = new @formulaclass(owner) fFormula2 = new @formulaclass2(owner) fTransfer = new @transferclass(owner) fheight = new @heightvalue(owner) fTransform = new @transform(owner) fTransform2 = new @transform2(owner) endfunc ; initialize the object complex func Init(const complex pz) fZ = fFormula.Init(pz) if @dual fZ2 = fFormula2.Init(pz) endif fTransform.init(fZ) fTransform2.init(fZ) fTransfer.Init(pz) fheight.Init(pz) fMinDist = 1e20 m_sflag = false fIterz = 0 fOldz = 0 iter = 0 return fZ endfunc ; call for each iterated point complex func Iterate() iter1 = false iter2 = false switch1 = false switch2 = false foldz = fZ if @dual if iter % (@seqgap1) >= 0 && @seqgap2 != 0 switch1 = true switch2 = false endif if (iter % (@seqgap1) >= (iter % @seqgap2)+1) || @seqgap2 == 0 switch1 = false switch2 = true endif if @seqgap2 > @seqgap1 switch1 = true switch2 = false endif endif if !@dual || @flavor == "Merge" || (@flavor == "Sequence" && @seqmethod == \ "Default") iter1 = true iter2 = true elseif @dual && @flavor == "Sequence" && @seqmethod == "By Iter Value" && \ switch1 iter1 = true elseif @dual && @flavor == "Sequence" && @seqmethod == "By Iter Value" && \ switch2 iter2 = true endif if @v_slopehelper >= 101 notx = true if @combine == "Tx1 Fr1 Fr2 Tx2" if (iter >= @prestart && iter < (@prestart+@preend))&& @transform != NullTransform fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength) if iter1 fZ = fFormula.iterate(fZ) endif if @dual if @flavor == "Sequence" fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength) if iter2 fZ = fFormula2.iterate(fZ) endif elseif @flavor == "Merge" fZ2 = (fZ2 + fTransform.Iterate(fZ2)*@strength)/(1+@strength) fZ2 = fFormula2.iterate(fZ2) endif endif notx = false endif if (iter >= @poststart && iter < (@poststart+@postend))&& @transform2 != NullTransform if iter1 fZ = fFormula.iterate(fZ) endif fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2) if @dual if @flavor == "Sequence" if iter2 fZ = fFormula2.iterate(fZ) endif fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2) elseif @flavor == "Merge" fZ2 = fFormula2.Iterate(fZ2) fZ2 = (fZ2 + fTransform2.Iterate(fZ2)*@strength2)/(1+@strength2) endif endif notx = false endif elseif @combine == "Tx1 Fr1 Tx2 Fr2" if (iter >= @prestart && iter < (@prestart+@postend))&& @transform != NullTransform fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength) if iter1 fZ = fFormula.iterate(fZ) endif if @dual if @flavor == "Sequence" fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength) if iter2 fZ = fFormula2.iterate(fZ) endif elseif @flavor == "Merge" fZ2 = (fZ2 + fTransform.Iterate(fZ2)*@strength)/(1+@strength) fZ2 = fFormula2.iterate(fZ2) endif endif notx = false endif if (iter >= @poststart && iter < (@poststart+@postend))&& @transform2 != NullTransform fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2) if iter1 fZ = fFormula.iterate(fZ) endif if @dual if @flavor == "Sequence" fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2) if iter2 fZ = fFormula2.iterate(fZ) endif elseif @flavor == "Merge" fZ2 = (fZ2 + fTransform2.Iterate(fZ2)*@strength2)/(1+@strength2) fZ2 = fFormula2.Iterate(fZ2) endif endif notx = false endif elseif @combine == "Fr1 Tx1 Tx2 Fr2" if (iter >= @prestart && iter < (@prestart+@postend))&& @transform != NullTransform if iter1 fZ = fFormula.iterate(fZ) endif fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength) if @dual if @flavor == "Sequence" if iter2 fZ = fFormula2.iterate(fZ) endif fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength) elseif @flavor == "Merge" fZ2 = fFormula2.iterate(fZ2) fZ2 = (fZ2 + fTransform.Iterate(fZ2)*@strength)/(1+@strength) endif endif notx = false endif if (iter >= @poststart && iter < (@poststart+@postend))&& @transform2 != NullTransform fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2) if iter1 fZ = fFormula.iterate(fZ) endif if @dual if @flavor == "Sequence" fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2) if iter2 fZ = fFormula2.iterate(fZ) endif elseif @flavor == "Merge" fZ2 = (fZ2 + fTransform2.Iterate(fZ2)*@strength2)/(1+@strength2) fZ2 = fFormula2.Iterate(fZ2) endif endif notx = false endif elseif @combine == "Fr1 Tx1 Fr2 Tx2" if (iter >= @prestart && iter < (@prestart+@postend))&& @transform != NullTransform if iter1 fZ = fFormula.iterate(fZ) endif fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength) if @dual if @flavor == "Sequence" if iter2 fZ = fFormula2.iterate(fZ) endif fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength) elseif @flavor == "Merge" fZ2 = fFormula2.iterate(fZ2) fZ2 = (fZ2 + fTransform.Iterate(fZ2)*@strength)/(1+@strength) endif endif notx = false endif if (iter >= @poststart && iter < (@poststart+@postend))&& @transform2 != NullTransform if iter1 fZ = fFormula.iterate(fZ) endif fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2) if @dual if @flavor == "Sequence" if iter2 fZ = fFormula2.iterate(fZ) endif fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2) elseif @flavor == "Merge" fZ2 = fFormula2.Iterate(fZ2) fZ2 = (fZ2 + fTransform2.Iterate(fZ2)*@strength2)/(1+@strength2) endif endif notx = false endif endif if notx if iter1 fZ = fFormula.iterate(fZ) endif if @dual if @flavor == "Sequence" if iter2 fZ = fFormula2.iterate(fZ) endif elseif @flavor == "Merge" fZ2 = fFormula2.iterate(fZ2) endif endif endif iter = iter + 1 if @dual && @flavor == "Merge" if @merget == "A+B" fZ = (fZ + fZ2)*@scale elseif @merget == "A+1/B" fZ = (fZ + 1/fZ2)*@scale elseif @merget == "1/A+B" fZ = (1/fZ + fZ2)*@scale elseif @merget == "A*B" fZ = (fZ*fZ2)*@scale elseif @merget == "A/B" fZ = (fZ/fZ2)*@scale elseif @merget == "B/A" fZ = (fZ2/fZ)*@scale elseif @merget == "Largest(A,B)" if cabs(fZ) < cabs(fZ2) fZ = fZ2 endif elseif @merget == "Largest(A,1/B)" if cabs(fZ) < cabs(1/fZ2) fZ = fZ2 endif elseif @merget == "Largest(1/A,B)" if cabs(1/fZ) < cabs(fZ2) fZ = fZ2 endif elseif @merget == "Smallest(A,B)" if cabs(fZ) > cabs(fZ2) fZ = fZ2 endif elseif @merget == "Smallest(A,1/B)" if cabs(fZ) > cabs(1/fZ2) fZ = fZ2 endif elseif @merget == "Smallest(1/A,B)" if cabs(1/fZ) > cabs(fZ2) fZ = fZ2 endif endif endif else fZ = fFormula.iterate(fZ) endif float d = fheight.Iterate(fZ) if d == -10000 m_sflag = true endif if @tx d = cabs(fheight.GetTransformedPoint()) endif if d < fMinDist && !m_sflag fMinDist = d endif if m_sflag if @formulaclass == DivergentFormula fIterz = fIterz + exp(-cabs(fZ)) else fIterz = fIterz + exp(-1/(cabs(fOldz - fZ))) endif endif return fZ endfunc bool func IsBailedOut() return fFormula.IsBailedOut(fZ) endfunc ; determine continuous iteration (height) float func CalcHeight(int iter) float height = fMinDist if m_sflag height = fIterz endif return fTransfer.Iterate(height) endfunc private: Formula fFormula Formula fFormula2 UserTransform fTransform UserTransform fTransform2 float fMinDist Transfer fTransfer complex fZ complex fZ2 TrapShape fheight bool m_sflag complex fOldz float fIterz int iter bool notx bool iter1 bool iter2 bool switch1 bool switch2 default: int param v_slopehelper caption = "Version (REB Slope Helper)" 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_slopehelper < 101 endparam UserTransform param transform caption = "Pre transform" default = NullTransform expanded = false visible = @v_slopehelper >= 101 endparam int param prestart caption = "Start Iter (Pre)" default = 0 visible = @transform != NullTransform && @v_slopehelper >= 101 endparam int param preend caption = "Iterations (Pre)" default = 1 visible = @transform != NullTransform && @v_slopehelper >= 101 endparam float param strength caption = "Strength (Pre)" default = 1 visible = @transform != NullTransform && @v_slopehelper >= 101 endparam bool param dual caption = "Use dual formulas" default = false visible = @v_slopehelper >= 101 endparam param combine caption = "Combine Order" default = 0 enum ="Tx1 Fr1 Fr2 Tx2" "Tx1 Fr1 Tx2 Fr2" "Fr1 Tx1 Tx2 Fr2" "Fr1 Tx1 Fr2 Tx2" visible = @dual && @v_slopehelper >= 101 endparam param flavor caption = "Combine Type" default = 0 enum = "Sequence" "Merge" visible = @dual && @v_slopehelper >= 101 endparam param seqmethod caption = "Sequence method" default = 0 enum = "Default" "By Iter Value" visible = @dual && @flavor == "Sequence" && @v_slopehelper >= 101 \ && @formulaclass != REB_Slope endparam int param seqgap1 caption = "Iteration cycle" default = 4 visible = @dual && @flavor == "Sequence" && @formulaclass != REB_Slope &&\ @seqmethod == "By Iter Value" && @v_slopehelper >= 101 endparam heading text = "'Formula 1 iters' must be less than or equal to the 'Iteration cycle' \ Out of range values will be truncated to the size of the 'Iteration \ cycle'." visible = @dual && @formulaclass != REB_Slope && @flavor == "Sequence" \ && @seqmethod == "By Iter Value" endheading int param seqgap2 caption = "Formula 1 Iters" default = 2 visible = @dual && @formulaclass != REB_Slope && @flavor == "Sequence" \ && @seqmethod == "By Iter Value" endparam param merget caption = "Merge Type" default = 0 enum = "A+B" "A+1/B" "1/A+B" "A*B" "A/B" "B/A" "Largest(A,B)" "Largest(A,1/B)"\ "Largest(1/A,B)" "Smallest(A,B)" "Smallest(A,1/B)" "Smallest(1/A,B)" visible = @dual && @flavor == "Merge" && @v_slopehelper >= 101 endparam float param scale caption = "Merge Scale" default = 1.0 visible = @dual && @flavor == "Merge" && (@merget == "A+B" || @merget == "A+1/B" \ || @merget == "1/A+B" || @merget == "A*B" || @merget == "A/B" || \ @merget == "B/A" ) && @v_slopehelper >= 101 endparam Formula param formulaClass caption = "Fractal Formula" default = REB_Julia endparam Formula param formulaClass2 caption = "Fractal Formula" default = REB_IkenagaJulia visible = @dual && @v_slopehelper >= 101 endparam UserTransform param transform2 caption = "Post transform" default = NullTransform expanded = false visible = @v_slopehelper >= 101 endparam int param poststart caption = "Start Iter (Post)" default = 0 visible = @transform2 != NullTransform && @v_slopehelper >= 101 endparam int param postend caption = "Iterations (Post)" default = 1 visible = @transform2 != NullTransform && @v_slopehelper >= 101 endparam float param strength2 caption = "Strength (Post)" default = 1 visible = @transform2 != NullTransform && @v_slopehelper >= 101 endparam TrapShape param heightvalue caption = "Height value" default = REB_TrapShapeSlopeBasic endparam Transfer param transferclass caption = "Height Transfer" default = Standard_HeightTransfer hint = "Selects a class that can transform the calculated height value." expanded = false endparam bool param tx caption = "Use transformed value" default = false visible = @heightvalue != REB_TrapShapeSlopeBasic endparam }
Constructor Summary | |
---|---|
REB_SlopeHelper()
|
|
REB_SlopeHelper(REB_Slope owner)
constructor |
Method Summary | |
---|---|
float |
CalcHeight(int iter)
determine continuous iteration (height) |
complex |
Init(complex pz)
initialize the object |
boolean |
IsBailedOut()
|
complex |
Iterate()
call for each iterated point |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public REB_SlopeHelper(REB_Slope owner)
public REB_SlopeHelper()
Method Detail |
---|
public complex Init(complex pz)
public complex Iterate()
public boolean IsBailedOut()
public float CalcHeight(int iter)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |