jlb
Class JLB_SlopeHelper

Object
  extended by jlb:JLB_SlopeHelper

class 
Object:JLB_SlopeHelper

Helper class for JLB_SlopeWithShapes.

Makes possible the use of any object formula with JLB_SlopeWithShapes. Works for both convergent and divergent formulas. Manages height values as trap shapes.


Ultra Fractal Source

Toggle UF Source Code Display

 class JLB_SlopeHelper {
 ; Helper class for JLB_SlopeWithShapes. <br>
 ; <p>
 ; Makes possible the use of any object formula with JLB_SlopeWithShapes. Works for both
 ; convergent and divergent formulas. Manages height values as trap shapes.
 public:
   import "common.ulb"
   import "Standard.ulb"
   import "reb.ulb"
   import "mmf.ulb"
 
   ; constructor
   func JLB_SlopeHelper(JLB_SlopeWithShapes owner)
     fContraction = new @ContractionClass(owner)
     fContraction2 = new @ContractionClass2(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, complex pc)
     fContraction.Init(pz, pc)
     fZ = pz                  ; Contraction.Init has no return value
     if @dual
       fContraction2.Init(pz, pc)
       fZ2 = 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(complex fC)
     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 = fContraction.iterate(fZ, fC)
           endif
           if @dual
             if @flavor == "Sequence"
               fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength)
               if iter2
                 fZ = fContraction2.iterate(fZ, fC)
               endif
             elseif @flavor == "Merge"
               fZ2 = (fZ2 + fTransform.Iterate(fZ2)*@strength)/(1+@strength)
               fZ2 = fContraction2.iterate(fZ2, fC)
             endif
           endif
           notx = false
         endif
         if (iter >= @poststart && iter < (@poststart+@postend))&& @transform2 != NullTransform
           if iter1
             fZ = fContraction.iterate(fZ, fC)
           endif
           fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2)
           if @dual
             if @flavor == "Sequence"
               if iter2
                 fZ = fContraction2.iterate(fZ, fC)
               endif
               fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2)
             elseif @flavor == "Merge"
               fZ2 = fContraction2.Iterate(fZ2, fC)
               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 = fContraction.iterate(fZ, fC)
           endif
           if @dual
             if @flavor == "Sequence"
               fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength)
               if iter2
                 fZ = fContraction2.iterate(fZ, fC)
               endif
             elseif @flavor == "Merge"
               fZ2 = (fZ2 + fTransform.Iterate(fZ2)*@strength)/(1+@strength)
               fZ2 = fContraction2.iterate(fZ2, fC)
             endif
           endif
           notx = false
         endif
         if (iter >= @poststart && iter < (@poststart+@postend))&& @transform2 != NullTransform
           fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2)
           if iter1
             fZ = fContraction.iterate(fZ, fC)
           endif
           if @dual
             if @flavor == "Sequence"
               fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2)
               if iter2
                 fZ = fContraction2.iterate(fZ, fC)
               endif
             elseif @flavor == "Merge"
               fZ2 = (fZ2 + fTransform2.Iterate(fZ2)*@strength2)/(1+@strength2)
               fZ2 = fContraction2.Iterate(fZ2, fC)
             endif
           endif
           notx = false
         endif
       elseif @combine == "Fr1 Tx1 Tx2 Fr2"
         if (iter >= @prestart && iter < (@prestart+@postend))&& @transform != NullTransform
           if iter1
             fZ = fContraction.iterate(fZ, fC)
           endif
           fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength)
           if @dual
             if @flavor == "Sequence"
               if iter2
                 fZ = fContraction2.iterate(fZ, fC)
               endif
               fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength)
             elseif @flavor == "Merge"
               fZ2 = fContraction2.iterate(fZ2, fC)
               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 = fContraction.iterate(fZ, fC)
           endif
           if @dual
             if @flavor == "Sequence"
               fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2)
               if iter2
                 fZ = fContraction2.iterate(fZ, fC)
               endif
             elseif @flavor == "Merge"
               fZ2 = (fZ2 + fTransform2.Iterate(fZ2)*@strength2)/(1+@strength2)
               fZ2 = fContraction2.Iterate(fZ2, fC)
             endif
           endif
           notx = false
         endif
       elseif @combine == "Fr1 Tx1 Fr2 Tx2"
         if (iter >= @prestart && iter < (@prestart+@postend))&& @transform != NullTransform
           if iter1
             fZ = fContraction.iterate(fZ, fC)
           endif
           fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength)
           if @dual
             if @flavor == "Sequence"
               if iter2
                 fZ = fContraction2.iterate(fZ, fC)
               endif
               fZ = (fZ + fTransform.Iterate(fZ)*@strength)/(1+@strength)
             elseif @flavor == "Merge"
               fZ2 = fContraction2.iterate(fZ2, fC)
               fZ2 = (fZ2 + fTransform.Iterate(fZ2)*@strength)/(1+@strength)
             endif
           endif
           notx = false
         endif
         if (iter >= @poststart && iter < (@poststart+@postend))&& @transform2 != NullTransform
           if iter1
             fZ = fContraction.iterate(fZ, fC)
           endif
           fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2)
           if @dual
             if @flavor == "Sequence"
               if iter2
                 fZ = fContraction2.iterate(fZ, fC)
               endif
               fZ = (fZ + fTransform2.Iterate(fZ)*@strength2)/(1+@strength2)
             elseif @flavor == "Merge"
               fZ2 = fContraction2.Iterate(fZ2, fC)
               fZ2 = (fZ2 + fTransform2.Iterate(fZ2)*@strength2)/(1+@strength2)
             endif
           endif
           notx = false
         endif
       endif
       if notx
         if iter1
           fZ = fContraction.iterate(fZ, fC)
         endif
         if @dual
           if @flavor == "Sequence"
             if iter2
               fZ = fContraction2.iterate(fZ, fC)
             endif
           elseif @flavor == "Merge"
             fZ2 = fContraction2.iterate(fZ2, fC)
           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 = fContraction.iterate(fZ, fC)
     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 @ContractionClass == 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:
   Contraction fContraction
   Contraction fContraction2
   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 (JLB 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 \
 ;                 && @ContractionClass != JLB_SlopeWithShapes
     visible = @dual  && @flavor == "Sequence"  && @v_slopehelper >= 101
   endparam
   int param seqgap1
     caption = "Iteration cycle"
     default = 4
 ;     visible = @dual && @flavor == "Sequence"   && @ContractionClass != JLB_SlopeWithShapes &&\
 ;               @seqmethod == "By Iter Value"  && @v_slopehelper >= 101
     visible = @dual && @flavor == "Sequence" && \
               @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  && @ContractionClass != JLB_SlopeWithShapes && @flavor == "Sequence" \
 ;               && @seqmethod == "By Iter Value"
     visible = @dual && @flavor == "Sequence" \
               && @seqmethod == "By Iter Value"
   endheading
   int param seqgap2
     caption = "Formula 1 Iters"
     default = 2
 ;     visible = @dual  && @ContractionClass != JLB_SlopeWithShapes && @flavor == "Sequence" \
 ;               && @seqmethod == "By Iter Value"
     visible = @dual && @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
   Contraction param ContractionClass
     caption = "Fractal Formula"
     default = JLB_MandelbrotContraction
   endparam
   Contraction param ContractionClass2
     caption = "Fractal Formula 2"
     default = JLB_IkenagaContraction
     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
JLB_SlopeHelper()
           
JLB_SlopeHelper(JLB_SlopeWithShapes owner)
          constructor
 
Method Summary
 float CalcHeight(int iter)
          return fFormula.IsBailedOut(fZ) endfunc determine continuous iteration (height)
 complex Init(complex pz, complex pc)
          initialize the object
 complex Iterate(complex fC)
          call for each iterated point
 
Methods inherited from class Object
 

Constructor Detail

JLB_SlopeHelper

public JLB_SlopeHelper(JLB_SlopeWithShapes owner)
constructor


JLB_SlopeHelper

public JLB_SlopeHelper()
Method Detail

Init

public complex Init(complex pz,
                    complex pc)
initialize the object


Iterate

public complex Iterate(complex fC)
call for each iterated point


CalcHeight

public float CalcHeight(int iter)
return fFormula.IsBailedOut(fZ) endfunc determine continuous iteration (height)