jlb
Class JLB_TrapShapeGIPlus

Object
  extended by common:Generic
      extended by common:TrapShape
          extended by jlb:JLB_TrapShapeGIPlus

class 
TrapShape:JLB_TrapShapeGIPlus

An extension of the Gaussian Integer shape in Standard.ulb, and to the G. I. colorings in Standard.ucl and lkm.ucl.

The original version uses a square grid of points covering the complex plane. This version generalizes the grid to points of the form n1*v1 + n2*v2, where the complex numbers v1 and v2 are specified by the user, and n1 and n2 are integers. Two special cases are a square grid, as in the original, and a triangular grid. Two added normalization factors are 1/pixel and 1/f(z) Code adapted from Standard.ulb


Ultra Fractal Source

Toggle UF Source Code Display

 class JLB_TrapShapeGIPlus(common.ulb:TrapShape) {
   ; An extension of the Gaussian Integer shape in Standard.ulb,
   ; and to the G. I. colorings in Standard.ucl and lkm.ucl.<p>
   ;
   ; The original version uses a square grid of points covering
   ; the complex plane. This version generalizes the grid to points
   ; of the form n1*v1 + n2*v2, where the complex numbers v1 and v2
   ; are specified by the user, and n1 and n2 are integers.
   ;
   ; Two special cases are a square grid, as in the original, and
   ; a triangular grid.
   ;
   ; Two added normalization factors are 1/pixel and 1/f(z)
   ;
   ; Code adapted from Standard.ulb
 
 public:
 
   func JLB_TrapShapeGIPlus(Generic pparent)
     TrapShape.TrapShape(pparent)
 
     if (@gridtype == "square")
       a1 = 1
       b1 = 0
       a2 = 0
       b2 = 1
       det = 1
     elseif (@gridtype == "triangular")
       a1 = 1
       b1 = 0
       a2 = 0.5                  ; = cos(60 degrees)
       b2 = sqrt(3.0)/2          ; = sin(60 degrees)
       det = b2
     else;if(@gridtype == "custom")
       a1 = @r1*cos(@ang1*#pi/180)
       b1 = @r1*sin(@ang1*#pi/180)
       float ang2 = @ang1 + @delta
       a2 = @r2*cos(ang2*#pi/180)
       b2 = @r2*sin(ang2*#pi/180)
       det = a1*b2-a2*b1
     endif
     ; The basis functions for the grid
     v1 = a1 + flip(b1)
     v2 = a2 + flip(b2)
   endfunc
 
   func Init(complex pz)
     if (@norm == "none")
       fNormFactor = 1
     elseif (@norm == "pixel")
       fNormFactor = #pixel
     elseif (@norm == "factor")
       fNormFactor = @fac
     elseif (@norm == "f(z)")
       fNormFactor = @normfunc(pz)
     elseif (@norm == "1/pixel")
       fNormFactor = 1/#pixel
     elseif (@norm == "factor")
       fNormFactor = @fac
     else;if (@norm == "f(z)")
       fNormFactor = 1/@normfunc(pz)
     endif
   endfunc
 
   float func Iterate(complex pz)
     pz = pz / fNormFactor
     ; Find c1 and c2 so that pz = c1*v1 + c2*v2.
     ; This is unique if det != 0, impossible if det = 0.
     float x = real(pz)
     float y = imag(pz)
     float c1 =  (x*b2-y*a2)/det
     float c2 = -(x*b1-y*a1)/det
     complex temp
     if @inttype == "round(z)"
       temp = round(c1)*v1 + round(c2)*v2
     elseif @inttype == "trunc(z)"
       temp = trunc(c1)*v1 + trunc(c2)*v2
     elseif @inttype == "floor(z)"
       temp = floor(c1)*v1 + floor(c2)*v2
     else;if @inttype == "ceil(z)"
       temp = ceil(c1)*v1 + ceil(c2)*v2
     endif
     return cabs(pz - temp * fNormFactor)
   endfunc
 
 private:
   complex fNormFactor
   complex v1
   complex v2
 
   float a1
   float b1
   float a2
   float b2
   float det
 
 default:
   title = "G.I. Plus"
   param gridtype
     caption = "Grid Type"
     enum = "square" "triangular" "custom"
     default = 0
     hint = "Selects grid type"
   endparam
   float param r1
     caption = "r1"
     default = 1.0
     min = 0
     hint = "Polar coordinates for v1 are r1 and ang1."
     visible = @gridtype >1
   endparam
   float param ang1
     caption = "angle 1"
     default = 0.0
     hint = "degrees"
     visible = @gridtype >1
   endparam
   float param r2
     caption = "r2"
     default = 1.0
     min = 0
     hint = "Polar coordinates for v2 are r2 and ang2, where \
       ang2 = ang1 + delta."
     visible = @gridtype >1
   endparam
   float param delta
     caption = "delta"
     default = 90
     min = 1
     max = 179
     hint = "(degrees) 1 <= delta <= 179"
     visible = @gridtype >1
   endparam
   param inttype
     caption="Integer Type"
     default=0
     enum="round(z)" "trunc(z)" "floor(z)" "ceil(z)"
     hint="Selects between four ways of reducing the orbit value z to an \
           integer. Each produces different effects."
   endparam
   param norm
     caption="Normalization"
     default=0
     enum="none" "pixel" "factor" "f(z)" "1/pixel" "1/f(z)"
     hint="Selects an optional normalization to be applied."
   endparam
   param fac
     caption=" Factor"
     default=(2.0,1.0)
     visible = @norm == "factor"
     hint="Specifies the normalization factor to be used if Normalization is \
           'factor'. Large factors give less-busy coloring."
   endparam
   func normfunc
     caption=" Function"
     default=ident()
     hint="Selects function to be used if Normalization is 'f(z)' or '1/f(z)'."
     visible = (@norm == "f(z)") ||(@norm == "1/f(z)")
   endfunc
 }
 


Constructor Summary
JLB_TrapShapeGIPlus()
           
JLB_TrapShapeGIPlus(Generic pparent)
           
 
Method Summary
 void Init(complex pz)
          call this before each sequence of values to be trapped
 float Iterate(complex pz)
          call this for each iteration being trapped
 
Methods inherited from class common:TrapShape
GetColorChannel, GetTextureValue, GetTransformedPoint, IterateSilent, SetThreshold
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

JLB_TrapShapeGIPlus

public JLB_TrapShapeGIPlus(Generic pparent)

JLB_TrapShapeGIPlus

public JLB_TrapShapeGIPlus()
Method Detail

Init

public void Init(complex pz)
Description copied from class: TrapShape
call this before each sequence of values to be trapped

Overrides:
Init in class TrapShape

Iterate

public float Iterate(complex pz)
Description copied from class: TrapShape
call this for each iteration being trapped

Overrides:
Iterate in class TrapShape