ck
Class SphericalLinear

Object
  extended by common:Generic
      extended by ck:InterpolateBase
          extended by ck:SphericalLinear

class 
InterpolateBase:SphericalLinear

Spherical Linear Interpolation between two Complex numbers


Ultra Fractal Source

Toggle UF Source Code Display

 class SphericalLinear(ck.ulb:InterpolateBase) {
 ; Spherical Linear Interpolation between two Complex numbers
 public:
          import "Common.ulb"
          func SphericalLinear (Generic pparent)
               InterpolateBase.InterpolateBase(pparent)
          endfunc
 
 protected:
           complex func doInterpolate(float t,complex a,complex b)
                   complex _a=(0,0)
                   complex _b=(0,0);
                   float absa=cabs(a);
                   float absb=cabs(b);
 
                   if(absa>0)
                           _a=a/absa
                   endif
                   
                   if(absb>0)
                             _b=b/absb
                   endif
 
                  float omega=(real(_a)*real(_b)+imag(_a)*imag(_b));
                  float sinomega=sin(omega)
                  if(sinomega==0)
                                 sinomega=0.00000000001
                  endif
                  
                  complex res=lerp(t,absa,absb)* ((sin((1-t)*omega)*_a+sin(t*omega)*_b)/sinomega)
 
                  return res;
 endfunc
 
 private:
      
       float func lerp(float t,float a,float b)
                  return  a + t * (b - a)
           endfunc
 
        
 default:
         title = "SphericalLinear"
         rating = recommended
 
 }
 


Constructor Summary
SphericalLinear()
           
SphericalLinear(Generic pparent)
           
 
Method Summary
protected  complex doInterpolate(float t, complex a, complex b)
           
 
Methods inherited from class ck:InterpolateBase
Interpolate
 
Methods inherited from class common:Generic
GetParent
 
Methods inherited from class Object
 

Constructor Detail

SphericalLinear

public SphericalLinear(Generic pparent)

SphericalLinear

public SphericalLinear()
Method Detail

doInterpolate

protected complex doInterpolate(float t,
                                complex a,
                                complex b)
Overrides:
doInterpolate in class InterpolateBase