reb
Class Monnier_HyperbolicTiling

Object
  extended by common:Generic
      extended by common:Transform
          extended by common:UserTransform
              extended by reb:Monnier_HyperbolicTiling

class 
UserTransform:Monnier_HyperbolicTiling

Based upon the uxf of Samuel Monnier and used with his permission.


Ultra Fractal Source

Toggle UF Source Code Display

 class Monnier_HyperbolicTiling(common.ulb:UserTransform) {
 ; Based upon the uxf of Samuel Monnier and used with his permission. <br>
 public:
   import "common.ulb"
 
    ; constructor
    func Monnier_HyperbolicTiling(Generic pparent)
      UserTransform.UserTransform(pparent)
    endfunc
 
    ; initialize the objects
    func Init(complex pz)
       UserTransform.Init(pz)
       if !@itertx
        complex z = pz
        zt = 0
        nz = 0
        if cabs(z) > 1 && @mode != 1
          m_solid = true
        endif
        h = sqrt(cos(pi/@k)^2/(cos(pi/@k)^2-sin(pi/@n)^2))
        r = sqrt(h^2-1)
        arg = 0
        arg2 = 0
        ratio = 0
        int i = 0
 
        if @mode == 1
          i = @niter
        endif
 
        while i < @niter
          i = i + 1
 
          arg = atan2(z)
          arg = -round(arg/(2*pi)*@n)/@n*(2*pi)
          zt = z*exp(1i*arg)
          if cabs(zt-h) > r
            if @sym == 0
              nz = abs(zt)
            elseif @sym == 1
              nz = zt
            elseif @sym == 2
              nz = z
            endif
            i = @niter
          else
            z = h+r^2/(zt-h)
          endif
        endwhile
      endif
    endfunc
 
   ; call for each iterated point
   complex func Iterate(complex pz)
     UserTransform.Iterate(pz)
       if @itertx
        complex z = pz
        zt = 0
        nz = 0
        if cabs(z) > 1 && @mode != 1
          m_solid = true
        endif
        h = sqrt(cos(pi/@k)^2/(cos(pi/@k)^2-sin(pi/@n)^2))
        r = sqrt(h^2-1)
        arg = 0
        arg2 = 0
        ratio = 0
        int i = 0
 
        if @mode == 1
          i = @niter
        endif
 
        while i < @niter
          i = i + 1
 
          arg = atan2(z)
          arg = -round(arg/(2*pi)*@n)/@n*(2*pi)
          zt = z*exp(1i*arg)
          if cabs(zt-h) > r
            if @sym == 0
              nz = abs(zt)
            elseif @sym == 1
              nz = zt
            elseif @sym == 2
              nz = z
            endif
            i = @niter
          else
            z = h+r^2/(zt-h)
          endif
        endwhile
      endif
 
     if @mode == 1
       nz = 0.4*pz + 0.2 + 0.1i
       arg = atan2(nz)
       if @sym == 0
         if arg < 0 || arg > pi/@n || cabs(nz-h) < r || cabs(nz) > 1
           if (real(#screenpixel + imag(#screenpixel))%2) == 0
             m_solid = true
           endif
         endif
       elseif @sym == 1
         if abs(arg) > pi/@n || cabs(nz-h) < r
           if (real(#screenpixel + imag(#screenpixel))%2) == 0
             m_solid = true
           endif
         endif
       elseif @sym == 2
         arg = -round(arg/(2*pi)*@n)/@n*(2*pi)
         zt = nz*exp(1i*arg)
         if cabs(zt-h) < r
           if (real(#screenpixel + imag(#screenpixel))%2) == 0
             m_solid = true
           endif
         endif
       endif
     endif
     nz = nz*exp(-1i*pi/180*@rot)/@magn + @center
 
     if @corrmap
       arg = atan2(nz)
       arg = -round(arg/(2*pi)*@n)/@n*(2*pi)
       nz = nz*exp(1i*arg)
       arg2 = atan2(nz)
       ratio = (cos(arg2)*h-sqrt(r^2-h^2*sin(arg2)^2))*cos(arg2)
 
       nz = nz/ratio*exp(-1i*(arg-pi/2))
     endif
 
     return nz
   endfunc
 
  protected:
    complex nz
    complex zt
    float arg
    float arg2
    float h
    float ratio
    float r
 
 default:
   title = "Monnier Hyperbolic Tiling"
   int param v_monnierhyperbolictiling
     caption = "Version (Hyperbolic Tiling)"
     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_monnierhyperbolictiling < 100
   endparam
   heading
     text = "Iterates the transform initialization for each iterated value of the \
             pixel. May give very interesting effects but may dramatically slow \
             the transform."
     visible = @itertx
   endheading
   param itertx
     caption = "Iterate transform"
     default = false
   endparam
   param mode
     caption = "Mode"
     default = 0
     enum = "Mapping" "One Tile"
   endparam
 
   param n
     caption = "n"
     default = 3
   endparam
 
   param k
     caption = "k"
     default = 7
   endparam
 
   param sym
     caption = "Symetry"
     default = 2
     enum = "Mirror+Rotation" "Rotation only" "None"
   endparam
 
   param center
     caption = "Mapping Center"
     default = (0,0)
   endparam
 
   param rot
     caption = "Mapping Rotation"
     default = 0.0
   endparam
 
   param magn
     caption = "Mapping Magnification"
     default = 1.0
   endparam
 
   param corrmap
     caption = "Correct Mapping ?"
     default = true
   endparam
 
   param niter
     caption = "Iteration Number"
     default = 1000
   endparam
 }
 


Constructor Summary
Monnier_HyperbolicTiling()
           
Monnier_HyperbolicTiling(Generic pparent)
          constructor
 
Method Summary
 void Init(complex pz)
          initialize the objects
 complex Iterate(complex pz)
          call for each iterated point
 
Methods inherited from class common:Transform
IsSolid, IterateSilent
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

Monnier_HyperbolicTiling

public Monnier_HyperbolicTiling(Generic pparent)
constructor


Monnier_HyperbolicTiling

public Monnier_HyperbolicTiling()
Method Detail

Init

public void Init(complex pz)
initialize the objects

Overrides:
Init in class Transform
Parameters:
pz - the value representing the sequence; for a normal transformation formula use, this will be #pixel. In some cases this may differ from the first value passed to Iterate() if the calling code applies some other transformations.

Iterate

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

Overrides:
Iterate in class Transform
Parameters:
pz - the complex value to be transformed
Returns:
the transformed value