reb
Class REB_TentMapJulia

Object
  extended by common:Generic
      extended by common:Formula
          extended by common:DivergentFormula
              extended by reb:REB_TentMapJulia

class 
DivergentFormula:REB_TentMapJulia

Julia version of the Tent Map as described in Wikipedia and Mathworld.

This version of the tent map has somewhat different initializing conditions from those used by Kerry Mitchell. For this version: T(x) = s*x for x <= 0.5
T(x) = s*(1-x) for x > 0.5

An inverted form is available, along with several tent types and two flavors.


Ultra Fractal Source

Toggle UF Source Code Display

 class REB_TentMapJulia(common.ulb:DivergentFormula) {
 ; Julia version of the Tent Map as described in Wikipedia and Mathworld. <br>
 ; <p>
 ; This version of the tent map has somewhat different initializing conditions
 ; from those used by Kerry Mitchell. For this version:
 ;    T(x) = s*x for x <= 0.5  <br>
 ;    T(x) = s*(1-x) for x > 0.5 <br>
 ; <p> An inverted form is available, along with several tent types and two
 ; flavors.
 public:
   import "common.ulb"
 
   ; constructor
   func REB_TentMapJulia(Generic pparent)
      DivergentFormula.DivergentFormula(pparent)
    endfunc
 
   ; initialize the formula
   complex func Init(complex pz)
     DivergentFormula.Init(pz)
     m_c = pz
     if @invert
       pz = 1/(m_c+(0.000001,0.000001))
     endif
     if @flavor == "Flavor 1"
       pz = @tentfn(pz)
     endif
     return pz
   endfunc
 
   ; call for every iterated point
   complex func Iterate(complex pz)
     DivergentFormula.Iterate(pz)
     if @flavor == "Flavor 2"
       pz = @tentfn(pz)
     endif
     if @invert
       if @type == "cabs"
         if cabs(@tentfn2(pz)) <= @tent3
           pz = @tent1*pz/(@seed+(0.000001,0.000001))
         else
           pz = @tent1*(@tent2-pz)/(@seed+(0.000001,0.000001))
         endif
       elseif @type == "real"
         if real(@tentfn2(pz)) <= @tent3
           pz = @tent1*pz/(@seed+(0.000001,0.000001))
         else
           pz = @tent1*(@tent2-pz)/(@seed+(0.000001,0.000001))
         endif
       elseif @type == "imag"
         if imag(@tentfn2(pz)) <= @tent3
           pz = @tent1*pz/(@seed+(0.000001,0.000001))
         else
           pz = @tent1*(@tent2-pz)/(@seed+(0.000001,0.000001))
         endif
       else
         if imag(@tentfn2(pz)) > @tent3
           pz = @tent1*(@tent2-pz)/(@seed+(0.000001,0.000001))
         elseif real(@tentfn2(pz)) > @tent3
           pz = @tent1*(@tent2-pz)/(@seed+(0.000001,0.000001))
         else
           pz = @tent1*pz/(@seed+(0.000001,0.000001))
         endif
       endif
     else
       if @type == "cabs"
         if cabs(@tentfn2(pz)) <= @tent3
           pz = @tent1*pz*@seed
         else
           pz = @tent1*(@tent2-pz)*@seed
         endif
       elseif @type == "real"
         if real(@tentfn2(pz)) <= @tent3
           pz = @tent1*pz*@seed
         else
           pz = @tent1*(@tent2-pz)*@seed
         endif
       elseif @type == "imag"
         if imag(@tentfn2(pz)) <= @tent3
           pz = @tent1*pz*@seed
         else
           pz = @tent1*(@tent2-pz)*@seed
         endif
       else
         if imag(@tentfn2(pz)) > @tent3
           pz = @tent1*(@tent2-pz)*@seed
         elseif real(@tentfn2(pz)) > @tent3
           pz = @tent1*(@tent2-pz)*@seed
         else
           pz = @tent1*pz*@seed
         endif
       endif
     endif
     return pz
   endfunc
 
   ; Override the default function for bailout
   bool func IsBailedOut(complex pz)
     bool bail = false
     if @test == 0
       bail = (|pz| > @p_bailout)
     elseif @test == 1
       bail = (sqr(real(pz)) > @p_bailout)
     elseif @test == 2
       bail = (sqr(imag(pz)) > @p_bailout)
     elseif @test == 3
       bail = (sqr(real(pz)) > @p_bailout || sqr(imag(pz)) > @p_bailout)  
     elseif @test == 4
       bail = (sqr(real(pz)) > @p_bailout && sqr(imag(pz)) > @p_bailout)  
     elseif @test == 5
       bail = (sqr(abs(real(pz)) + abs(imag(pz))) > @p_bailout)
     elseif @test == 6
       bail = (sqr(real(pz) + imag(pz)) > @p_bailout)
     endif
     return bail
   endfunc
   
 protected:
   complex m_c  
 
 default:
   title = "Tent Map Julia"
   int param v_tentmapjulia
     caption = "Version (Tent Map Julia)"
     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_tentmapjulia < 101
   endparam
   heading
     text = "Based upon the Tent Map function:"
   endheading
   heading
     text = "   T(x) = s*x for x <= 0.5"
   endheading
   heading
     text = "   T(x) = s*(1-x) for x > 0.5"
   endheading
   heading
     text = "and the code for the Barnsley type fractals."
   endheading
   param type
     caption = "Tent type"
     default = 3
     enum = "cabs" "real" "imag" "Pinsky"
   endparam
   param flavor
     caption = "Flavor"
     default = 0
     enum = "Flavor 1" "Flavor 2"
   endparam
   bool param invert
     caption = "Inversion"
     default = false
   endparam
   param test
     caption = "Bailout Test"
     default = 0
     enum = "mod" "real" "imag" "or" "and" "manh" "manr"
   endparam
   float param p_bailout
     caption = "Bailout value"
     default = 10000
     min = 1
   endparam
   float param tent1
     caption ="Tent param #1"
     default = 1
   endparam
   float param tent2
     caption ="Tent param #2"
     default = 1
   endparam
   float param tent3
     caption ="Tent param #3"
     default = 0.5
   endparam
   func tentfn
     caption = "Tent function"
     default = ident()
   endfunc
   func tentfn2
     caption = "Tent function #2"
     default = ident()
   endfunc
   complex param seed
     caption = "Julia seed"
     default = (1.04375,0.35625)
     hint = "Use this parameter to create many different Julia sets. A good \
             way to set this parameter is with the Eyedropper or Explore features."
   endparam
   complex param p_power ; Overrides p_power from Formula
     caption = "Power"
     default = (2,0)
     visible = false
   endparam
 }
 


Constructor Summary
REB_TentMapJulia()
           
REB_TentMapJulia(Generic pparent)
          constructor
 
Method Summary
 complex Init(complex pz)
          initialize the formula
 boolean IsBailedOut(complex pz)
          Override the default function for bailout
 complex Iterate(complex pz)
          call for every iterated point
 
Methods inherited from class common:DivergentFormula
GetUpperBailout
 
Methods inherited from class common:Formula
GetLowerBailout, GetPrimaryExponent
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

REB_TentMapJulia

public REB_TentMapJulia(Generic pparent)
constructor


REB_TentMapJulia

public REB_TentMapJulia()
Method Detail

Init

public complex Init(complex pz)
initialize the formula

Overrides:
Init in class DivergentFormula
Parameters:
pz - seed value for the sequence; for a normal fractal formula, this will be #pixel
Returns:
first value in the sequence; this corresponds to #z in a fractal formula

Iterate

public complex Iterate(complex pz)
call for every iterated point

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

IsBailedOut

public boolean IsBailedOut(complex pz)
Override the default function for bailout

Overrides:
IsBailedOut in class DivergentFormula
Parameters:
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.
Returns:
true if the sequence has bailed out (i.e. should be terminated)