reb
Class REB_TrapShapeInversions

Object
  extended by common:Generic
      extended by common:TrapShape
          extended by reb:REB_TrapShapeInversions

class 
TrapShape:REB_TrapShapeInversions

This shape uses sphere and mobius inversions


Ultra Fractal Source

Toggle UF Source Code Display

 class REB_TrapShapeInversions(common.ulb:TrapShape) {
  ; This shape uses sphere and mobius inversions <br>
  public:
    import "common.ulb"
 ;   import "reb.ulb"
 
 ; constructor
    func REB_TrapShapeInversions(Generic pparent)
      TrapShape.TrapShape(pparent)
      i = new @isph(this)
      ; z axis rotation correction
      zrot = (0,1)^(-#angle*2/#pi)
      i.recurse()
      cir = i.s
      max = i.fk
    endfunc
 
   ; Call this for each iteration being trapped.
    float func Iterate(complex pz)
     TrapShape.Iterate(pz)
     float distance = 1e10
     j = 0
     idx = 0
     inside = false
     while j < max && !inside
       if @shape == "functions"
         if cabs(@fn(pz)-(cir.sph[j].fcen+@offset)*zrot*@scale/#magn) < cir.sph[j].frad*@scale/#magn
           inside = true
           idx = j
         endif
       else
         if cabs(pz-(cir.sph[j].fcen+@offset)*zrot*@scale/#magn) < cir.sph[j].frad*@scale/#magn
           inside = true
           idx = j
         endif
       endif
       j = j + 1
     endwhile
     if inside
       if @shape == "rings"
         distance = abs(cir.sph[idx].frad*@scale/#magn-\
                  cabs(pz-(cir.sph[idx].fcen+@offset)*zrot*@scale/#magn))
       elseif @shape == "circles"
         distance = cabs(pz-(cir.sph[idx].fcen+@offset)*zrot*@scale/#magn)
       elseif @shape == "angle"
         distance = atan2(pz-(cir.sph[idx].fcen+@offset)*zrot*@scale/#magn)
         if distance < 0
           distance = distance + 2*#pi
         endif
         distance = distance/(2*#pi)
       elseif @shape == "functions"
         distance = cabs(@fn(pz)-(cir.sph[idx].fcen+@offset)*zrot*@scale/#magn)
       endif
     endif
     m_lastz = (cir.sph[idx].fcen+@offset)*zrot*@scale/#magn
     return distance/(cir.sph[idx].frad*@scale/#magn)
    endfunc
 
  protected:
   spherearray cir
   int max
   InvertSphere i
   complex zrot
   int j
   int idx
   bool inside
    
  default:
    title = "Inversions"
   int param v_trapshapeinversions
     caption = "Version (Trap Shape Inversions)"
     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_trapshapeinversions < 101
   endparam
   float param scale
     caption = "Inversions scale"
     default = 1.0
   endparam
   complex param offset
     caption = "Inversions offset"
     default = (0,0)
   endparam
   param shape
     caption = "Shape"
     default = 0
     enum = "rings" "circles" "angle" "functions"
   endparam
   func fn
     caption = "Shape function"
     default = sin()
     visible = @shape == "functions"
   endfunc
   InvertSphere param isph
     caption = "Inversions"
     default = InvertCircles
   endparam
  }
 


Constructor Summary
REB_TrapShapeInversions()
           
REB_TrapShapeInversions(Generic pparent)
          import "reb.ulb" constructor
 
Method Summary
 float Iterate(complex pz)
          Call this for each iteration being trapped.
 
Methods inherited from class common:TrapShape
GetColorChannel, GetTextureValue, GetTransformedPoint, Init, IterateSilent, SetThreshold
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

REB_TrapShapeInversions

public REB_TrapShapeInversions(Generic pparent)
import "reb.ulb" constructor


REB_TrapShapeInversions

public REB_TrapShapeInversions()
Method Detail

Iterate

public float Iterate(complex pz)
Call this for each iteration being trapped.

Overrides:
Iterate in class TrapShape