dmj5
Class DMJ_TrapSelect

Object
  extended by common:Generic
      extended by common:Generator
          extended by dmj5:DMJ_TrapSelect

class 
Generator:DMJ_TrapSelect

TrapSelect base class for choosing which iterations to trap. The TrapSelect class is a Generator that produces a sequence of values that are all 0 or 1. A 0 indicates the trap calculation should be skipped for this iteration; a 1 indicates the trap calculation should be performed at this iteration. You can derive other TrapSelect classes from this base class to indicate they adhere to the 0 or 1 convention.


Ultra Fractal Source

Toggle UF Source Code Display

 class DMJ_TrapSelect(common.ulb:Generator) {
   ; TrapSelect base class for choosing which iterations to trap.
   ;
   ; The TrapSelect class is a Generator that produces a
   ; sequence of values that are all 0 or 1. A 0 indicates
   ; the trap calculation should be skipped for this
   ; iteration; a 1 indicates the trap calculation should
   ; be performed at this iteration.
   ;
   ; You can derive other TrapSelect classes from this
   ; base class to indicate they adhere to the 0 or 1
   ; convention.
   
 public:
   import "common.ulb"
 
   ; Constructor
   ; @param pparent = a reference to the object creating the new object; typically, 'this'
   func DMJ_TrapSelect(Generic pparent)
     Generator.Generator(pparent)
   endfunc
   
   ; Set up for a sequence of values
   ;
   ; This function will be called at the beginning of each
   ; sequence of values (e.g. at the beginning of each fractal
   ; orbit).
   ; @param pz = seed value for the sequence
   ; @return first value in the sequence
   float func Init(float pz)
     Generator.Init(pz)
     
     ; Base class implementation flags the sequence to end
     ; immediately. We don't want this (this sequence proceeds
     ; indefinitely) so clear the flag.
     m_BailedOut = false
     m_FractionalIteration = @p_trapstart
     m_Trapping = false
     m_LoopCount = @p_traploop
     return pz
   endfunc
   
   ; Produce the next value in the sequence
   ;
   float func Iterate(float pz)
     Generator.Iterate(pz)
 
     if (@p_trapalliterations == 1)  ; we are skipping some iterations
       m_FractionalIteration = m_FractionalIteration - 1      ; one less to go before we trap
       while (m_FractionalIteration < 0.0)              ; iterations all used up
         if (m_Trapping)                      ; we are currently trapping
           m_Trapping = false                  ; so stop
           m_FractionalIteration = m_FractionalIteration + @p_trapskip  ; skip this many iterations
         else                          ; we aren't currently trapping
           m_Trapping = true                  ; so start
           m_FractionalIteration = m_FractionalIteration + @p_trapiter  ; do this many iterations
           m_LoopCount = m_LoopCount - 1
         endif
       endwhile
       
       if (m_LoopCount < 0)        ; loops exhausted; always return 0
         m_BailedOut = true        ; and flag the sequence to end
         return 0
       elseif (m_Trapping)
         return 1
       else
         return 0
       endif
     
     else
       return 1              ; always trapping
     endif
   endfunc
   
 protected:
   float m_FractionalIteration
   bool m_Trapping
   float m_LoopCount
 
 default:
   title = "Trap Select"
   
   int param v_dmj_trapselect
     caption = "Version (DMJ_TrapSelect)"
     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_dmj_trapselect < 100
   endparam
 
   int param p_trapalliterations
     caption = "Traps Apply To"
     default = 0
     enum = "all iterations" "some iterations"
     hint = "This option, if set to 'some iterations', allows you to apply the orbit traps to only some iterations (with extra options shown below)."
   endparam
   float param p_trapstart
     caption = "Start Iteration"
     default = 0.0
     hint = "This is the iteration at which to start watching for orbit traps."
     visible = @p_trapalliterations == 1
   endparam
   float param p_trapiter
     caption = "Trap Iterations"
     default = 10.0
     hint = "This is the number of iterations to watch for traps in a single block."
     visible = @p_trapalliterations == 1
   endparam
   float param p_trapskip
     caption = "Skip Iterations"
     default = 10.0
     hint = "This is the number of iterations to skip watching for traps, after a block of watched iterations."
     visible = @p_trapalliterations == 1
   endparam
   float param p_traploop
     caption = "Loop Count"
     default = 1e20
     hint = "This is the number of times to perform the trap/don't trap cycle; after this many trap/don't trap cycles, trapping will stop."
     visible = @p_trapalliterations == 1
   endparam
 }
 


Constructor Summary
DMJ_TrapSelect()
           
DMJ_TrapSelect(Generic pparent)
          Constructor
 
Method Summary
 float Init(float pz)
          Set up for a sequence of values This function will be called at the beginning of each sequence of values (e.g.
 float Iterate(float pz)
          Produce the next value in the sequence
 
Methods inherited from class common:Generator
InitDefault, IsBailedOut
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

DMJ_TrapSelect

public DMJ_TrapSelect(Generic pparent)
Constructor

Parameters:
pparent - = a reference to the object creating the new object; typically, 'this'

DMJ_TrapSelect

public DMJ_TrapSelect()
Method Detail

Init

public float Init(float pz)
Set up for a sequence of values This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).

Overrides:
Init in class Generator
Parameters:
pz - = seed value for the sequence
Returns:
first value in the sequence

Iterate

public float Iterate(float pz)
Produce the next value in the sequence

Overrides:
Iterate in class Generator
Parameters:
pz - previous value in the sequence. 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.
Returns:
the next value in the sequence