; comment { by Ron Barnett
July 3, 2008
revised Dec 12, 2012
Ron's Website

This is my public collection. As much as possible, I will try to keep these backwards-compatible, so that all of your parameters will always render correctly in the future.

1. Quaternion/Hypercomplex math
2. Misc 3D 4D Methods including mandelbulb and Msltoe 3D
3. Mobius Transformations
4. 3D Rotations
5. 3D Object classes
6. 3D Inversion classes
7. Trap shape classes
8. Image TrapMode classes
9. Image Trap ColorMode classes
10. Trap Transfer classes
11. Image Traps class
12. Color Trap classes
13. Formula object classes
14. Formula Switch Classes 15. Direct Color Arrays
16. Direct Coloring Classes
18. Line Art Plugins
19. Transformation classes
20. 3D Mesh Classes
21. Raytrace Classes
22. Convolution filters
23. Generator classes
24. Formula classes for embossing
} ;------------------------------------------- ; Quaternion/Hypercomplex math ;------------------------------------------- Class QH { import "common.ulb" ; Functions for Quaternion and Hypercomplex operations.
;

; For quaternions, multiplication is not commutative and division is always ; defined. ;

; For hypercomplex, multiplication is commutative and division is not always ; defined. The inverses which are not defined lieon two orthogonal ; 4D hyperplanes. ;

; The hypercomplex code is based upon the complex number methods of Clyde ; Davenport using his complex/complex model. ;

; H1 = [a1,a2]
;

; where a1 and a2 are both complex numbers. This is the method used in Fractint. ; a1 and a2 are converted to two new complex numbers: ;

; fa1 = a1 - conj(flip(a2))
; fa2 = a1 + conj(flip(a2))
;

; These new complex numbers (and correspondingly fb1 and fb2) can be used for ; ordinary complex math, including multiplication, division, trancendental ; functions, powers, etc. For example, sqrt: ;

; fa1 = sqrt(fa1)
; fa2 = sqrt(fa2)
;

; A second conversion is done at the end of the operation(s): ;

; c1 = 0.5*(fa1+fa2)
; c2 = 0.5*(conj(flip(fa1)) - conj(flip(fa2)))
;

; H2 = [c1, c2]
;

; T(z) = (az+b)/(cz+d)
;

; T is a Mobius Transformation were z, a, b, c and d are complex ; numbers. T is typically represented in normalized matrix form: ;

; T = | a b |
; | c d |
;

; T is normalized if the determinant of ad-bc = 1
;

; A Mobius Transformation can be viewed as a composition of translation, ; scaling and inversion. ;

;

;

; this is the base class
; it contains methods for
; 1. sphere initialization for base and generator sets
; 2. sphere inversion
; 3. recursion
; 4. heapsort and duplicate removal
;

; This is a child of InvertSphere. For the case of 3 base circles ; (Apollonian Gasket) methods for perturbation of the initiating circles ; are available. ;

; Mathematical Curves
;
;

;

; Used with his permission.
public: import "common.ulb" func Monnier_SFBM_II_Texture(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; call before each iteration func Init(complex pz) TrapShape.Init(pz) if @v_monniersfbm < 102 || (!@init && @v_monniersfbm >= 102) z = 0 zc1 = 0 zc2 = 0 zc3 = 0 zc4 = 0 i = 0 j = 0 jmax = 0 niter = 0 a = 0 sum = 0 x = 0 y = 0 d1 = 0 d2 = 0 d3 = 0 d4 = 0 nindex = 0 sindex = 0 scale = 1 cr1r = 0 cr1i = 0 cr2r = 0 cr2i = 0 cr3r = 0 cr3i = 0 cr4r = 0 cr4i = 0 crp1 = 0 crp2 = 0 crp3 = 0 crp4 = 0 norm = 1 if @interp == 0 niter = ceil(real(log(real(@fmm)-imag(@fmm))/log(1+@mstep))) else niter = ceil((real(@fmm)-imag(@fmm))/@mstep) endif if @mode == 0 jmax = 1 else jmax = 5 endif endif endfunc ; call for each iterated point float func Iterate(complex pz) TrapShape.Iterate(pz) if @v_monniersfbm >= 102 && @init z = 0 zc1 = 0 zc2 = 0 zc3 = 0 zc4 = 0 i = 0 j = 0 jmax = 0 niter = 0 a = 0 sum = 0 x = 0 y = 0 d1 = 0 d2 = 0 d3 = 0 d4 = 0 nindex = 0 sindex = 0 scale = 1 cr1r = 0 cr1i = 0 cr2r = 0 cr2i = 0 cr3r = 0 cr3i = 0 cr4r = 0 cr4i = 0 crp1 = 0 crp2 = 0 crp3 = 0 crp4 = 0 norm = 1 if @interp == 0 niter = ceil(real(log(real(@fmm)-imag(@fmm))/log(1+@mstep))) else niter = ceil((real(@fmm)-imag(@fmm))/@mstep) endif if @mode == 0 jmax = 1 else jmax = 5 endif endif while j < jmax z = pz/@size if @mode == 1 || @mode == 2 if j == 0 a = @cbl + @ctl + @cbr + @ctr + @cc;/20 elseif j == 1 z = z + @eps*(-1,-1) a = -@cbl elseif j == 2 z = z + @eps*(-1,1) a = -@ctl elseif j == 3 z = z + @eps*(1,-1) a = -@cbr elseif j == 4 z = z + @eps*(1,1) a = -@ctr endif else a = 1 endif j = j + 1 i = 0 while i < niter + 2 if i == 2 if @pptype == 0 z = (real(@pp)*(1/sqrt(imag(@ppp))*x + 1i*sqrt(imag(@ppp))*y)^real(@ppp)+(1-real(@pp))*z)*imag(@pp) else z = (real(@pp)*x^real(@ppp)*exp(imag(@ppp)*1i*y)+(1-real(@pp))*z)*imag(@pp) endif elseif i == 0 z = z/imag(@pp) endif z = z*exp(1i*pi/180*@rot) + 1 - 2i if i > 1 if @interp == 0 scale = (1+@mstep)^(i-2)*imag(@fmm) else scale = real(@fmm)-(i-1)*(@mstep+.001) endif endif i = i + 1 zc = round(scale*z)/scale zc1 = zc + (.5,.5)/scale zc2 = zc + (-.5,.5)/scale zc3 = zc + (.5,-.5)/scale zc4 = zc + (-.5,-.5)/scale cr1r = ((real(zc1)-859-i)^5 % (132+i) - (imag(zc1)+328+i)^3 % (113+i))^2 %2 - 1 if @noise != 6 && @noise != 8 && @noise != 10 && @noise != 12 && @noise != 14 cr2r = ((real(zc2)-859-i)^5 % (132+i) - (imag(zc2)+328+i)^3 % (113+i))^2 %2 - 1 cr3r = ((real(zc3)-859-i)^5 % (132+i) - (imag(zc3)+328+i)^3 % (113+i))^2 %2 - 1 cr4r = ((real(zc4)-859-i)^5 % (132+i) - (imag(zc4)+328+i)^3 % (113+i))^2 %2 - 1 endif if @noise == 0 || @noise == 5 cr1i = ((real(zc1)-465+i)^3 % (120+i) - (imag(zc1)-756+i)^2 % (107+i))^2 %2 - 1 cr2i = ((real(zc2)-465+i)^3 % (120+i) - (imag(zc2)-756+i)^2 % (107+i))^2 %2 - 1 cr3i = ((real(zc3)-465+i)^3 % (120+i) - (imag(zc3)-756+i)^2 % (107+i))^2 %2 - 1 cr4i = ((real(zc4)-465+i)^3 % (120+i) - (imag(zc4)-756+i)^2 % (107+i))^2 %2 - 1 endif if @noise == 0 v1 = (z - zc1)*scale v2 = (z - zc2)*scale v3 = (z - zc3)*scale v4 = (z - zc4)*scale crp1 = cr1r*real(v1) + cr1i*imag(v1) crp2 = cr2r*real(v2) + cr2i*imag(v2) crp3 = cr3r*real(v3) + cr3i*imag(v3) crp4 = cr4r*real(v4) + cr4i*imag(v4) elseif @noise == 1 crp1 = cr1r crp2 = cr1r crp3 = cr1r crp4 = cr1r norm = .5 elseif @noise == 2 crp1 = cr1r crp2 = cr2r crp3 = cr1r crp4 = cr2r norm = .5 elseif @noise == 3 crp1 = cr1r crp2 = cr2r crp3 = cr3r crp4 = cr2r norm = .5 elseif @noise == 4 crp1 = -cr1r crp2 = cr2r crp3 = cr3r crp4 = -cr4r norm = .5 elseif @noise == 5 crp1 = cr1r*abs(real(z-zc)*scale)^real(@noisep) + cr1i*abs(imag(z-zc)*scale)^imag(@noisep) crp2 = cr2r*abs(real(z-zc)*scale)^real(@noisep) + cr2i*abs(imag(z-zc)*scale)^imag(@noisep) crp3 = cr3r*abs(real(z-zc)*scale)^real(@noisep) + cr3i*abs(imag(z-zc)*scale)^imag(@noisep) crp4 = cr4r*abs(real(z-zc)*scale)^real(@noisep) + cr4i*abs(imag(z-zc)*scale)^imag(@noisep) norm = .2 elseif @noise == 6 crp1 = (cabs(z-zc)*scale-imag(@noisep))^real(@noisep) norm = .4 elseif @noise == 7 crp1 = cr1r*(cabs(z-zc)*scale-imag(@noisep))^real(@noisep) crp2 = cr2r*(cabs(z-zc)*scale-imag(@noisep))^real(@noisep) crp3 = cr3r*(cabs(z-zc)*scale-imag(@noisep))^real(@noisep) crp4 = cr4r*(cabs(z-zc)*scale-imag(@noisep))^real(@noisep) norm = .4 elseif @noise == 8 arg = atan2(z-zc) arg = -round(arg/(2*pi)*4)/4*(2*pi) ztest = (z-zc)*exp(1i*arg) crp1 = (real(ztest)*scale-imag(@noisep))^real(@noisep) norm = .4 elseif @noise == 9 arg = atan2(z-zc) arg = -round(arg/(2*pi)*4)/4*(2*pi) ztest = (z-zc)*exp(1i*arg) crp1 = cr1r*(real(ztest)*scale-imag(@noisep))^real(@noisep) crp2 = cr2r*(real(ztest)*scale-imag(@noisep))^real(@noisep) crp3 = cr3r*(real(ztest)*scale-imag(@noisep))^real(@noisep) crp4 = cr4r*(real(ztest)*scale-imag(@noisep))^real(@noisep) norm = .4 elseif @noise == 10 arg = atan2(z-zc) arg = -round(arg/(2*pi)*8)/8*(2*pi) ztest = (z-zc)*exp(1i*arg) crp1 = (real(ztest)*scale-imag(@noisep))^real(@noisep) norm = .4 elseif @noise == 11 arg = atan2(z-zc) arg = -round(arg/(2*pi)*8)/8*(2*pi) ztest = (z-zc)*exp(1i*arg) crp1 = cr1r*(real(ztest)*scale-imag(@noisep))^real(@noisep) crp2 = cr2r*(real(ztest)*scale-imag(@noisep))^real(@noisep) crp3 = cr3r*(real(ztest)*scale-imag(@noisep))^real(@noisep) crp4 = cr4r*(real(ztest)*scale-imag(@noisep))^real(@noisep) norm = .4 elseif @noise == 12 ztest = z - zc if real(cr1r) > 0 d1 = abs(cabs(ztest*scale+(.5,.5))-.5) d2 = abs(cabs(ztest*scale-(.5,.5))-.5) if d2 < d1 d1 = d2 endif else d1 = abs(cabs(ztest*scale+(.5,-.5))-.5) d2 = abs(cabs(ztest*scale-(.5,-.5))-.5) if d2 < d1 d1 = d2 endif endif crp1 = d1^real(@noisep) norm = .4 elseif @noise == 13 ztest = z - zc if real(cr1r) > 0 d1 = abs(cabs(ztest*scale+(.5,.5))-.5) d2 = abs(cabs(ztest*scale-(.5,.5))-.5) if d2 < d1 d1 = d2 endif else d1 = abs(cabs(ztest*scale+(.5,-.5))-.5) d2 = abs(cabs(ztest*scale-(.5,-.5))-.5) if d2 < d1 d1 = d2 endif endif crp1 = cr1r*(d1^real(@noisep)-imag(@noisep)) crp2 = cr2r*(d1^real(@noisep)-imag(@noisep)) crp3 = cr3r*(d1^real(@noisep)-imag(@noisep)) crp4 = cr4r*(d1^real(@noisep)-imag(@noisep)) norm = .4 elseif @noise == 14 ztest = (z - zc)*scale if real(cr1r) > 0 d1 = abs(real(ztest) - imag(ztest) -.5) d2 = abs(real(ztest) - imag(ztest) +.5) if d2 < d1 d1 = d2 endif else d1 = abs(real(ztest) + imag(ztest) -.5) d2 = abs(real(ztest) + imag(ztest) +.5) if d2 < d1 d1 = d2 endif endif crp1 = d1^real(@noisep) norm = .4 elseif @noise == 15 ztest = (z - zc)*scale if real(cr1r) > 0 d1 = abs(real(ztest) - imag(ztest) -.5) d2 = abs(real(ztest) - imag(ztest) +.5) if d2 < d1 d1 = d2 endif else d1 = abs(real(ztest) + imag(ztest) -.5) d2 = abs(real(ztest) + imag(ztest) +.5) if d2 < d1 d1 = d2 endif endif crp1 = cr1r*(d1^real(@noisep)-imag(@noisep)) crp2 = cr2r*(d1^real(@noisep)-imag(@noisep)) crp3 = cr3r*(d1^real(@noisep)-imag(@noisep)) crp4 = cr4r*(d1^real(@noisep)-imag(@noisep)) norm = .4 elseif @noise == 16 endif if @noise == 6 || @noise == 8 || @noise == 10 || @noise == 12 || @noise == 14 nindex = crp1 else d1 = real(z - zc)*scale + 0.5 d2 = (1 - d1) d3 = imag(z - zc)*scale + 0.5 d4 = (1 - d3) d1 = (.5 + .5*sin(pi*d1-pi/2))^@power d2 = (.5 + .5*sin(pi*d2-pi/2))^@power d3 = (.5 + .5*sin(pi*d3-pi/2))^@power d4 = (.5 + .5*sin(pi*d4-pi/2))^@power nindex = crp1*d1*d3 + crp3*d1*d4 + crp2*d2*d3 + crp4*d2*d4 endif if @f1 == 1 nindex = real(sin(100*real(@fp1)*nindex+imag(@fp1)))/10 elseif @f1 == 2 nindex = real(@fp1)*10*nindex+2+imag(@fp1) if abs(nindex) > 1 nindex = 1 endif nindex = real(asin(nindex))/4 elseif @f1 == 3 nindex = 20*real(@fp1)*nindex+1+imag(@fp1) if abs(nindex) > 1 nindex = 1 endif nindex = real(acos(nindex))/4 elseif @f1 == 4 nindex = real(atanh(20*real(@fp1)*nindex+imag(@fp1)))/8 elseif @f1 == 5 nindex = (20*nindex+imag(@fp1))^(2+real(@fp1))/160 elseif @f1 == 6 nindex = real((15*nindex+imag(@fp1))^(.1*real(@fp1))) elseif @f1 == 7 nindex = real(exp(10*real(@fp1)*nindex+imag(@fp1)-.5))/8 elseif @f1 == 8 nindex = real(round(5*real(@fp1)*nindex+imag(@fp1)/5))/4 elseif @f1 == 9 nindex = real(round(15*real(@fp1)*nindex+imag(@fp1)/5)^.1)/3 elseif @f1 == 10 if real(@fp1)<0.0 nindex = (sin(-(real(z)+(4+imag(@fp1))*nindex))+cos(-(imag(z)+(4+imag(@fp1))*nindex)))/15 else nindex = (sin(5*sqrt(real(@fp1))*(real(z)+(4+imag(@fp1))*nindex))+cos(5*1/sqrt(real(@fp1))*(imag(z)+(4+imag(@fp1))*nindex)))/15 endif endif if @f2 == 1 nindex = real(sin(100*real(@fp2)*nindex+imag(@fp2)))/10 elseif @f2 == 2 nindex = real(@fp2)*10*nindex+2+imag(@fp2) if abs(nindex) > 1 nindex = 1 endif nindex = real(asin(nindex))/4 elseif @f2 == 3 nindex = 20*real(@fp2)*nindex+1+imag(@fp2) if abs(nindex) > 1 nindex = 1 endif nindex = real(acos(nindex))/4 elseif @f2 == 4 nindex = real(atanh(20*real(@fp2)*nindex+imag(@fp2)))/8 elseif @f2 == 5 nindex = (20*nindex+imag(@fp2))^(2+real(@fp2))/160 elseif @f2 == 6 nindex = real((15*nindex+imag(@fp2))^(.1*real(@fp2))) elseif @f2 == 7 nindex = real(exp(10*real(@fp2)*nindex+imag(@fp2)-.5))/8 elseif @f2 == 8 nindex = real(round(5*real(@fp2)*nindex+imag(@fp2)/5))/4 elseif @f2 == 9 nindex = real(round(15*real(@fp2)*nindex+imag(@fp2)/5)^.1)/3 elseif @f2 == 10 if real(@fp2)<0.0 nindex = (sin(-(real(z)+(4+imag(@fp2))*nindex))+cos(-(imag(z)+(4+imag(@fp2))*nindex)))/15 else nindex = (sin(5*sqrt(real(@fp2))*(real(z)+(4+imag(@fp2))*nindex))+cos(5*1/sqrt(real(@fp2))*(imag(z)+(4+imag(@fp2))*nindex)))/15 endif endif nindex = real(nindex^@power2) if i == 1 x = nindex elseif i == 2 y = nindex else sindex = sindex + nindex/scale^@beta endif endwhile if @mode != 2 sum = sum + a*sindex else sum = sum + a*abs(sindex) endif sindex = 0 scale = 1 endwhile if @mode == 2 sum = 3*abs(sum) endif if @mode == 1 sindex = sum/(10*@eps*(abs(@cbl + @ctl + @cbr + @ctr)+1)) else sindex = sum endif if @interp == 0 d = 2*norm*sindex/(niter)^.5 else d = .4*norm*sindex endif if @v_monniersfbm >= 104 z = exp(flip(2 * #pi * sqrt(2) * d)) endif m_lastz = z return d endfunc protected: complex z complex zc1 complex zc2 complex zc3 complex zc4 int i int j int jmax int niter float a float sum float x float y float d1 float d2 float d3 float d4 float nindex float sindex float scale float cr1r float cr1i float cr2r float cr2i float cr3r float cr3i float cr4r float cr4i float crp1 float crp2 float crp3 float crp4 float norm float d default: title = "Monnier's S.F.B.M. II Texture" int param v_monniersfbm caption = "Version (Monnier's S.F.B.M. II Texture)" default = 104 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_monniersfbm < 104 endparam param init caption = "Init with each iter" default = true visible = @v_monniersfbm >= 102 endparam param size caption = "Pattern Size" default = 0.1 endparam param noise caption = "Noise Function" default = 0 enum = "Perlin" "Raw Gird" "Strips" "Corners" "Checkerboard" \ "Soft Gird" "Circles" "Soft Circles" "Squares" "Soft Squares" \ "Octogons" "Soft Octogons" "Roundy Truchet" "Soft Roundy Truchet" \ "Squarry Truchet" "Soft Squarry Truchet" endparam param noisep caption = "Noise F. Parameters" default = (.2,.5) hint = "Noise Function Parameters" endparam param f1 caption = "flavor 1" default = 0 enum = "Original" "Wavy" "Blobs" "Cut" "Messy" "Soft I" "Strings" "Soft II" "Sharp" "String-Sharp" "Random Phase" endparam param fp1 caption = "flavor 1 Parameters" default = (1,0) hint = "flavor 1 Parameters" endparam param f2 caption = "flavor 2" default = 0 enum = "Original" "Wavy" "Blobs" "Cut" "Messy" "Soft I" "Strings" "Soft II" "Sharp" "String-Sharp" "Random Phase" endparam param fp2 caption = "flavor 2 Parameters" default = (1,0) hint = "flavor 2 Parameters" endparam param mode caption = "Mode" default = 0 enum = "Normal" "Convolution" "Absolute Convolution" endparam param beta caption = "Beta (Spectral Density Parameter)" default = 1.0 hint = "Spectral Density Exponent" endparam param power caption = "Power" default = 2.0 endparam param power2 caption = "Post-Power" default = 1.0 endparam param pp caption = "Pre-Processing" default = (0,1) endparam param pptype caption = "Pre-Processing Type" default = 0 enum = "Cartesian" "Polar" hint = "Pre-Processing Type" endparam param ppp caption = "Pre-P. Power and Aspect" default = (1,1) hint = "Pre-Processing Power and Aspect" endparam param rot caption = "Rotation Step" default = 28.0 endparam param mstep caption = "Frequency Separation" default = 1.0 hint = "Frequency Separation" endparam param fmm caption = "Inv. of max/min Frequency" default = (40,1) hint = "Inverse of max/min Frequency" endparam param interp caption = "Frequency Interpolation" default = 0 enum = "Logarithmic" "Linear" hint = "Frequency Interpolation" endparam param cc caption = "Center Extra Weight" default = 0.0 endparam param cbl caption = "Bottom Left Weight" default = 1.0 endparam param ctl caption = "Top Left Weight" default = 0.0 endparam param cbr caption = "Bottom Right Weight" default = 0.0 endparam param ctr caption = "Top Right Weight" default = 0.0 endparam param eps caption = "Epsilon" default = 0.006 endparam } class REB_TrapShapeSlopeBasic(common.ulb:TrapShape) { ; Provides the basic trap shapes for Slope with Shapes.
public: import "common.ulb" ; constructor func REB_TrapShapeSlopeBasic(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; call for each iterated point float func Iterate(complex pz) TrapShape.Iterate(pz) float m_d = 0 if @zmode == 0 m_d = -10000 elseif @zmode == 1 m_d = |pz|; get current distance from origin elseif @zmode == 2 m_d = abs(real(pz)); get current distances from i axis elseif @zmode == 3 m_d = abs(imag(pz)); get current distances from r axis elseif @zmode == 4 m_d = abs(real(pz))+abs(imag(pz)); get current distances from i axis elseif @zmode == 5 m_d = abs(atan2(pz)); get current angles elseif @zmode == 6 m_d = -20000 endif m_lastZ = pz return m_d endfunc default: title = "Slope Basics" int param v_slopebasics caption = "Version (Slope Basics)" 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_slopebasics < 101 endparam heading text = "This plugin provides the basic slope height values." endheading param zmode caption = "Basic heights" default = 0 enum = "smoothed iteration" "smallest |z|" "smallest |real(z)|" \ "smallest |imag(z)|" "smallest summ(z)" "smallest |atan(z)|" endparam } class REB_ImageTileTexture(common.ulb:TrapShape) { ; ; Uses an image to create a texture.
;

; Converts the colors of an imported image to greyscale and then converts ; the greyscale value to a complex number to use as a texture. ; public: import "common.ulb" ; Constructor func REB_ImageTileTexture(Generic pparent) TrapShape.TrapShape(pparent) m_img = new @f_image(0) m_empty = m_img.GetEmpty() endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) color pcolor = rgba(0,0,0,0) if !m_empty complex m_zi = (0,1)^(@iangle/90.0) complex m_zs = (0,1)^(@sangle/90.0) complex pzrs = pz ; offset if !@itile pzrs = pzrs+@ioffset endif ; aspect ratio pzrs = real(pzrs) + flip(imag(pzrs)*@iaspect) ; rotation pzrs = pzrs*m_zi ; skew pzrs = real(pzrs)*m_zs + flip(imag(pzrs)) float width = m_img.getWidth() float height = m_img.getHeight() if @itile if @v_trapshapeimagetiletexture >= 103 pzrs = (pzrs+500+flip(500))*@scale*500 else pzrs = (pzrs+#width/2+flip(#height/2))*@scale*#width endif complex c = @adjx-2*((real(pzrs) % (width-1))/width) + \ flip(@adjy-2*((imag(pzrs) % (height-1))/height)) pcolor = m_img.getColor(c) else pcolor = m_img.getColor(pzrs*@scale) endif endif m_LastZ = exp(flip(2 * #pi * sqrt(2) * (1 - (0.3 * red(pcolor)+ 0.59 * green(pcolor) + 0.11 * blue(pcolor))))) return 1 - (0.3 * red(pcolor)+ 0.59 * green(pcolor) + 0.11 * blue(pcolor)) endfunc protected: ImageImport m_img int m_image_width int m_image_height float m_ratio bool m_empty default: title = "Image Tile Texture" int param v_trapshapeimagetiletexture caption = "Version (Trap Shape Image Tile Texture)" default = 103 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_trapshapeimagetiletexture < 103 endparam heading caption = "Image Parameters" endheading ImageImport param f_image caption = "Image" default = ImageImport endparam float param scale caption = "Image scale" default = 1 min = 0 hint = "Changes the scale of the image." endparam float param adjx caption = "Tile adj x" default = 0.99 min = 0.9 max = 1.1 endparam float param adjy caption = "Tile adj y" default = 0.999 min = 0.9 max = 1.1 endparam complex param ioffset caption = "Image offset" default = (0,0) visible = !@itile endparam float param iaspect caption = "Image aspect" default = 1.0 endparam float param iangle caption = "Image rotation" default = 0 hint = "Rotates the image" endparam float param sangle caption = "Image skew" default = 0 hint = "Skews the image" endparam bool param itile caption = "Tile the image" default = false endparam } class REB_TrapShapeChip(common.ulb:TrapShape) { ; Based upon the Chip strange attractor. Can also be used as a texture.
public: import "common.ulb" ; Constructor func REB_TrapShapeChip(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float x = real(pz)*@s float y = imag(pz)*@s float pxx = 0 int att_iter = 0 while att_iter < @max_att_iterations && x < 1e100 && x > -1e100 pxx = x if x != 0 x = y - x/abs(x)*cos(sqr(log(abs(@h2*x-@h3))))*atan(sqr(log(abs(@h3*x-@h2)))) else x = y - cos(sqr(log(abs(@h2*x-@h3))))*atan(sqr(log(abs(@h3*x-@h2)))) endif y = @h1 - pxx att_iter = att_iter + 1 endwhile m_LastZ = (x + sgn*flip(y)) float d = @distscale*|pz-(x + sgn*flip(y))| return d endfunc default: title = "Chip" heading text="Chip Attractor" endheading heading text="x -> y - sign(x)*cos(sqr(log(abs(b*x - c)))) \ * atan(sqr(log(abs(c*x - b))))" endheading heading text="y -> a - x" endheading int param v_trapshapechip caption = "Version (Trap Shape Chip)" 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_trapshapechip < 101 endparam float param h1 caption = "Chip param 1" default = -15 endparam float param h2 caption = "Chip param 2" default = -3 endparam float param h3 caption = "Chip param 3" default = 1 endparam float param distscale caption = "Distance scale" default = 0.01 endparam float param s caption = "Attractor scale" default = 40 endparam int param max_att_iterations caption = "Attractor iterations" default = 5 endparam bool param sgn caption = "Conjugate transform" default = false endparam } class REB_TrapShapeChip2(common.ulb:TrapShape) { ; Based upon the Chip strange attractor. Can also be used as a texture.
;

; This class can be used to explore in the two "hybridised" planes. ; Type SJ iterates in the "zc" plane, and type 3RDIM in the "cz" plane. ; The trap can create multiple fractal images of the chosen function. public: import "common.ulb" ; Constructor func REB_TrapShape4DOrbit(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) p = (0,0) px = pz*@scale c = 0 if @function == "Julia Frame-Robert" || @function == "Julia Ikenaga" || \ @function == "Julia Lambda" || @function == "Julia" px = @seed p = pz*@scale endif if @variant == "SJ" p = real(p) + flip(imag(p)*@r) c = @t + @r*real(px) + flip(imag(px)) else p = @r*real(p) + flip(imag(p)) c = @t + real(px) + flip(imag(px)*@r) endif p = @fn1(p) rt_iter = 0 while rt_iter < @max_iterations && (|p| < @bailout) if @function == "Mandelbrot" || @function == "Julia" p = p*p + c elseif @function == "Julia Lambda" p = c*p*(1-p) elseif @function == "Ikenaga" || @function == "Julia Ikenaga" p = p*p*p + (c-1)*p-c elseif @function == "Frame-Robert" || @function == "Julia Frame-Robert" p = p*p*p/5 + p*p + c endif rt_iter = rt_iter + 1 endwhile m_LastZ = @fn2(p) float d = abs(cabs(pz)-cabs(m_LastZ)) return d endfunc protected: complex p complex px complex c int rt_iter default: title = "4D Orbit" int param v_trapshape4dorbit caption = "Version (Trap Shape 4D Orbit)" 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_trapshape4dorbit < 101 endparam param t caption = "Translation" default = -0.75 endparam param r caption = "Tilt" default = 0.5 min = 0 max = 1 hint = "This parameter takes values between 0 and 1 inclusive." endparam param variant caption = "4D variant" default = 0 enum = "SJ" "3RDIM" hint = "These variants are based upon Gordon Lamb's 4D formulas." endparam param max_iterations caption = "4D iterations" hint = "This is the number of iterations for the 4D formula." default = 10 endparam float param bailout caption = "Bailout" default = 10000.0 endparam float param scale caption = "Scale" default = 1.0 endparam param function caption = "4D Fractal" default = 1 enum = "Frame-Robert" "Ikenaga" "Mandelbrot" "Julia Frame-Robert" \ "Julia Ikenaga" "Julia Lambda" "Julia" endparam complex param seed caption = "Julia seed" default = (0,0) visible = @function == "Julia Frame-Robert" || @function == "Julia Ikenaga" \ || @function == "Julia Lambda" || @function == "Julia" endparam func fn1 caption = "Pre Function" default = ident() endfunc func fn2 caption = "Post Function" default = ident() endfunc } class REB_TrapShapeCosMartin(common.ulb:TrapShape) { ; Uses the CosMartin strange attractor as the trap shape. Can also be used as a texture.
; CosMartin is the cosine variant of the Martin strange attractor.
public: import "common.ulb" ; Constructor func REB_TrapShapeCosMartin(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float x = real(pz)*@s float y = imag(pz)*@s float pxx = 0 int att_iter = 0 while att_iter < @max_att_iterations && x < 1e100 && x > -1e100 pxx = x x = y - cos(x) y = @h1 - pxx att_iter = att_iter + 1 endwhile m_LastZ = (x + sgn*flip(y)) float d = @distscale*|pz-(x + sgn*flip(y))| return d endfunc default: title = "CosMartin" heading text="CosMartin Attractor" endheading heading text="x -> y - cos(x)" endheading heading text="y -> a - x" endheading int param v_trapshapecosmartin caption = "Version (Trap Shape CosMartin)" 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_trapshapecosmartin < 101 endparam float param h1 caption = "CosMartin param" default = 6.28 endparam float param distscale caption = "Distance scale" default = 0.01 endparam float param s caption = "Attractor scale" default = 15 endparam int param max_att_iterations caption = "Attractor iterations" default = 5 endparam bool param sgn caption = "Conjugate transform" default = false endparam } class REB_TrapShapeCosMartin2(common.ulb:TrapShape) { ; Uses the CosMartin strange attractor as the trap shape. Can also be used as a texture.
; CosMartin is the cosine variant of the Martin strange attractor.
public: import "common.ulb" ; Constructor func REB_TrapShapeHopalong(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float x = real(pz)*@s float y = imag(pz)*@s float pxx = 0 int att_iter = 0 while att_iter < @max_att_iterations && x < 1e100 && x > -1e100 pxx = x if x != 0 x = y - x/abs(x)*sqrt(abs(@h2*x-@h3)) else x = y - sqrt(abs(@h2*x-3)) endif y = @h1 - pxx att_iter = att_iter + 1 endwhile m_LastZ = (x + sgn*flip(y)) float d = @distscale*|pz-(x + sgn*flip(y))| return d endfunc default: title = "Hopalong" heading text="Hopalong attractor" endheading heading text="x -> y - sign(x)*sqrt(abs(b*x-c))" endheading heading text="y -> a - x" endheading int param v_trapshapehopalong caption = "Version (Trap Shape Hopalong)" 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_trapshapehopalong < 101 endparam float param h1 caption = "Hopalong param 1" default = 0.4 endparam float param h2 caption = "Hopalong param 2" default = 1 endparam float param h3 caption = "Hopalong param 3" default = 0 endparam float param distscale caption = "Distance scale" default = 0.06 endparam float param s caption = "Attractor scale" default = 3 endparam int param max_att_iterations caption = "Attractor iterations" default = 5 endparam bool param sgn caption = "Conjugate transform" default = false endparam } class REB_TrapShapeKam_Torus(common.ulb:TrapShape) { ; This shape uses the Hopalong strange attractor. It can also be used as a texture.
;

;

;

;

;

;

;

; It can also be used as a texture ; public: import "common.ulb" ; constructor func REB_SpokesNRings(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; call for each iterated point float func Iterate(complex pz) TrapShape.Iterate(pz) float dist = cabs(pz) float theta = atan2(pz) if theta < 0 theta = theta + 2*#pi endif if theta > 2*#pi theta = 2*#pi endif float wedge = 2*#pi/@spokes float swidth = @swidth if swidth >= wedge swidth = wedge endif if @type == "Spokes" if @spiralize if (theta+@twist*dist) % wedge < (theta+@twist*dist+swidth) % wedge dist = 1e20 pz = (1e20,1e20) endif else if theta % wedge < (theta+swidth) % wedge dist = 1e20 pz = (1e20,1e20) endif endif elseif @type == "Rings" if dist % (1/@dens) < (dist+0.5*@rwidth/@dens) % (1/@dens) dist = 1e20 pz = (1e20,1e20) endif endif m_lastZ = pz return dist endfunc protected: default: title = "Spokes N Rings" int param v_spokesnrings caption = "Version (Trap Shape Spokes N Rings)" 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_spokesnrings < 100 endparam param type caption = "Trap Type" default = 0 enum = "Spokes" "Rings" endparam int param spokes caption = "# of Spokes" default = 5 visible = @type == "Spokes" endparam float param swidth caption = "Spoke thickness" default = 1 visible = @type == "Spokes" endparam bool param spiralize caption = "Spiral spokes" default = false visible = @type == "Spokes" endparam float param twist caption = "Amount of twist" default = 1 visible = @type == "Spokes" && @spiralize endparam float param dens caption = "Ring density" default = 20 visible = @type == "Rings" endparam float param rwidth caption = "Ring thickness" default = 1 visible = @type == "Rings" endparam } class REB_TrapShapeAmpersand(common.ulb:TrapShape) { ; This shape uses the ampersand function.
;

;

; This variant of the ophuiride function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeOphiuride(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = (0.01*@b*sin(theta)-@a*cos(theta))*tan(theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Ophiuride" int param v_trapshapeophiuride caption = "Version (Trap Shape Ophiuride)" 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_trapshapeophiuride < 101 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeREBAstroid(common.ulb:TrapShape) { ; This shape uses the astroid function.
;

; This variant of the astoid function is different from that used by Damien ; Jones. It has signed and absolute value version of the distance. The function ; also has a complex conjugate variant. The transformed value is the complex ; return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeREBAstroid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 complex as = 0 complex af1 = 0 complex af2 = 0 float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale if !@cmplx x = real(@fn1(pz)) y = imag(@fn2(pz)) else x = real(@fn1(pz)) y = imag(@fn1(pz)) endif if @ref == "pz" d = x^(2/3)+y^(2/3)-@a^(2/3)+cabs(pz)*@offset else d = x^(2/3)+y^(2/3)-@a^(2/3)+@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif af1 = @afn1(theta)^real(@pwr) af2 = @afn2(theta)^imag(@pwr) as = @ar*(af1+sgn*flip(af2)) m_LastZ = as if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - (as)) endif endif return d endfunc default: title = "Astroid REB" int param v_trapshapeastroidreb caption = "Version (Trap Shape Astroid REB)" default = 102 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_trapshapeastroidreb < 102 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 0.2 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param a caption = "parameter a" default = 1 visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam bool param cmplx caption = "Apply to complex" default = false visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula && !@cmplx endfunc float param ar caption = "Radius" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam complex param pwr caption = "Power" default = (3,3) hint = "Affects shape and scale of trap." visible = !@altformula endparam func afn1 caption = "Function #1" default = cos() visible = !@altformula endfunc func afn2 caption = "Function #2" default = sin() visible = !@altformula endfunc bool param sgn caption = "Conjugate transform" default = false visible = !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@altformula endparam bool param alttheta caption = "Alternate theta" default = false visible = !@altformula endparam } class REB_TrapShapeBean(common.ulb:TrapShape) { ; This shape uses the bean function.
;

; It has signed and absolute value version of the distance. The function ; also has a complex conjugate variant. The transformed value is the complex ; return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeBean(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) float theta = 0 TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = (x^2+y^2)^2-x^3-y^3-cabs(pz)*@offset else d = (x^2+y^2)^2-x^3-y^3-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else complex af1 = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif af1 = @a*(@afn1(theta)^real(@pwr)+@afn2(theta)^imag(@pwr)) if @absval d = abs(cabs(pz) - cabs(af1*cos(theta) + sgn*flip(af1*sin(theta)))) else d = cabs(pz - (af1*cos(theta) + sgn*flip(af1*sin(theta)))) endif m_LastZ = (af1*cos(theta) + sgn*flip(af1*sin(theta))) endif return d endfunc default: title = "Bean" int param v_trapshapebean caption = "Version (Trap Shape Bean)" 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_trapshapebean < 101 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 0.2 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam complex param pwr caption = "Power" default = (3,3) hint = "Affects shape and scale of trap." visible = !@altformula endparam func afn1 caption = "Function #1" default = cos() visible = !@altformula endfunc func afn2 caption = "Function #2" default = sin() visible = !@altformula endfunc bool param sgn caption = "Conjugate transform" default = false visible = !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@altformula endparam } class REB_TrapShapeCircle(common.ulb:TrapShape) { ; This shape uses the circle function.
;

; This variant of the circle function has a signed and absolute value ; version of the distance. The function also has a complex conjugate. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCircle(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a*sin(theta)^2 + 0.2*@b*cos(theta)^2 if @absval d = abs(cabs(pz) - cabs(rr*cos(theta) + sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) return d endfunc default: title = "Circle" int param v_trapshapecircle caption = "Version (Trap Shape Circle)" default = 102 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_trapshapecircle < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_AstroidalEllipsoid(common.ulb:TrapShape) { ; This shape uses the 3D Astroidal Ellipsoid function.
;

public: import "common.ulb" ; Constructor func REB_AstroidalEllipsoid(Generic pparent) TrapShape.TrapShape(pparent) xrot = (0,1)^(@xang/90) yrot = (0,1)^(@yang/90) temp = 0 endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = (@aa*cos(real(pz))*cos(imag(pz)))^3*@scale2 float y = (@ab*sin(real(pz))*cos(imag(pz)))^3*@scale2 float z = (@ac*sin(imag(pz)))^3*@scale2 ; ; Y axis rotation ; temp = x + flip(z) temp = temp*yrot x = real(temp) z = imag(temp) ; ; X axis rotation ; temp = y + flip(z) temp = temp*xrot y = real(temp) z = imag(temp) ; calculate 3D distance float d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +z^2)*@scale if @usez if @tz == "cabs(z)" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*cabs(pz)-z)^2)*@scale elseif @tz == "real+imag z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz)+imag(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((imag(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(imag(pz))-z)^2)*@scale elseif @tz == "angle pz" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*atan2(pz)-z)^2)*@scale endif endif m_lastZ = x + flip(y) return d endfunc protected: complex xrot complex yrot complex temp default: title = "Astroidal Ellipsoid" heading text = "This is a 3D parametric surface." endheading int param v_AstroidalEllipsoid caption = "Version (Trap Shape AstroidalEllipsoid)" 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_AstroidalEllipsoid < 100 endparam float param xang caption = "X rotation" default = -40 endparam float param yang caption = "Y rotation" default = 30 endparam float param scale2 caption = "prescale" default = 1.0 endparam float param scale caption = "Scale" default = 0.2 endparam bool param usez caption = "fractal z for z value" default = false endparam param tz caption = "fractal z type" enum = "cabs(z)" "real+imag z" "real z" "imag z" "angle pz" default = 0 visible = @usez endparam float param sz caption = "fractal z scale" default = 1 visible = @usez endparam float param aa caption = "param a" default = 1.0 endparam float param ab caption = "param b" default = 1.0 endparam float param ac caption = "param c" default = 1.0 endparam } class REB_AppleSurface(common.ulb:TrapShape) { ; This shape uses the 3D Apple Surface function.
;

public: import "common.ulb" ; Constructor func REB_AppleSurface(Generic pparent) TrapShape.TrapShape(pparent) xrot = (0,1)^(@xang/90) yrot = (0,1)^(@yang/90) temp = 0 endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = (cos(real(pz))*(4 + 3.8*cos(imag(pz))))*@ap*@scale2 float y = (sin(real(pz))*(4 + 3.8*cos(imag(pz))))*@ap*@scale2 float z = ((cos(imag(pz)) + sin(imag(pz)) - 1)+\ (1 + sin(imag(pz)))*log(1 - #pi*imag(pz) / 10) +\ 7.5*sin(imag(pz)))*@ap*@scale2 ; ; Y axis rotation ; temp = x + flip(z) temp = temp*yrot x = real(temp) z = imag(temp) ; ; X axis rotation ; temp = y + flip(z) temp = temp*xrot y = real(temp) z = imag(temp) ; calculate 3D distance float d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +z^2)*@scale if @usez if @tz == "cabs(z)" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*cabs(pz)-z)^2)*@scale elseif @tz == "real+imag z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz)+imag(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((imag(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(imag(pz))-z)^2)*@scale elseif @tz == "angle pz" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*atan2(pz)-z)^2)*@scale endif endif m_lastZ = x + flip(y) return d endfunc protected: complex xrot complex yrot complex temp default: title = "Apple Surface" heading text = "This is a 3D parametric surface." endheading int param v_AppleSurface caption = "Version (Trap Shape AppleSurface)" 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_AppleSurface < 100 endparam float param xang caption = "X rotation" default = -75 endparam float param yang caption = "Y rotation" default = 20 endparam float param scale2 caption = "Precale" default = 1.0 endparam float param scale caption = "Scale" default = 0.2 endparam bool param usez caption = "fractal z for z value" default = false endparam param tz caption = "fractal z type" enum = "cabs(z)" "real+imag z" "real z" "imag z" "angle pz" default = 0 visible = @usez endparam float param sz caption = "fractal z scale" default = 1 visible = @usez endparam float param ap caption = "param" default = 0.1 endparam } class REB_BowTie(common.ulb:TrapShape) { ; This shape uses the 3D Bow Tie Surface function.
;

public: import "common.ulb" ; Constructor func REB_BowTie(Generic pparent) TrapShape.TrapShape(pparent) xrot = (0,1)^(@xang/90) yrot = (0,1)^(@yang/90) temp = 0 endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = sin(real(pz))/(sqrt(2)+sin(imag(pz)))*@scale2 float y = sin(real(pz))/(sqrt(2)+cos(imag(pz)))*@scale2 float z = cos(real(pz))/(sqrt(2)+1)*@scale2 ; ; Y axis rotation ; temp = x + flip(z) temp = temp*yrot x = real(temp) z = imag(temp) ; ; X axis rotation ; temp = y + flip(z) temp = temp*xrot y = real(temp) z = imag(temp) ; calculate 3D distance float d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +z^2)*@scale if @usez if @tz == "cabs(z)" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*cabs(pz)-z)^2)*@scale elseif @tz == "real+imag z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz)+imag(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((imag(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(imag(pz))-z)^2)*@scale elseif @tz == "angle pz" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*atan2(pz)-z)^2)*@scale endif endif m_lastZ = x + flip(y) return d endfunc protected: complex xrot complex yrot complex temp default: title = "Bow Tie Surface" heading text = "This is a 3D parametric surface." endheading int param v_BowTieSurface caption = "Version (Trap Shape BowTieSurface)" 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_BowTieSurface < 100 endparam float param xang caption = "X rotation" default = -45 endparam float param yang caption = "Y rotation" default = 90 endparam float param scale2 caption = "Prescale" default = 1 endparam float param scale caption = "Scale" default = 0.2 endparam bool param usez caption = "fractal z for z value" default = false endparam param tz caption = "fractal z type" enum = "cabs(z)" "real+imag z" "real z" "imag z" "angle pz" default = 0 visible = @usez endparam float param sz caption = "fractal z scale" default = 1 visible = @usez endparam } class REB_BowSurface(common.ulb:TrapShape) { ; This shape uses the 3D Bow Surface function.
;

public: import "common.ulb" ; Constructor func REB_BowSurface(Generic pparent) TrapShape.TrapShape(pparent) xrot = (0,1)^(@xang/90) yrot = (0,1)^(@yang/90) temp = 0 endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = ((2 + @T*sin(2*#pi*real(pz)))*sin(4*#pi*imag(pz)))*@scale2 float y = (2 + @T*sin(2*#pi*real(pz)))*cos(4*#pi*imag(pz))*@scale2 float z = (@T*cos(2*#pi*real(pz)) + 3*cos(2*#pi*imag(pz))*@scale2) ; ; Y axis rotation ; temp = x + flip(z) temp = temp*yrot x = real(temp) z = imag(temp) ; ; X axis rotation ; temp = y + flip(z) temp = temp*xrot y = real(temp) z = imag(temp) ; calculate 3D distance float d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +z^2)*@scale if @usez if @tz == "cabs(z)" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*cabs(pz)-z)^2)*@scale elseif @tz == "real+imag z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz)+imag(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((imag(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(imag(pz))-z)^2)*@scale elseif @tz == "angle pz" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*atan2(pz)-z)^2)*@scale endif endif m_lastZ = x + flip(y) return d endfunc protected: complex xrot complex yrot complex temp default: title = "Bow Surface" heading text = "This is a 3D parametric surface." endheading int param v_BowSurface caption = "Version (Trap Shape BowSurface)" 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_BowSurface < 100 endparam float param xang caption = "X rotation" default = -100 endparam float param yang caption = "Y rotation" default = 30 endparam float param scale2 caption = "Prescale" default = 0.5 endparam float param scale caption = "Scale" default = 0.2 endparam float param T caption = "Bow thickness" default = 1 endparam bool param usez caption = "fractal z for z value" default = false endparam param tz caption = "fractal z type" enum = "cabs(z)" "real+imag z" "real z" "imag z" "angle pz" default = 0 visible = @usez endparam float param sz caption = "fractal z scale" default = 1 visible = @usez endparam } class REB_BoySurface(common.ulb:TrapShape) { ; This shape uses the 3D Boy Surface function.
;

public: import "common.ulb" ; Constructor func REB_BoySurface(Generic pparent) TrapShape.TrapShape(pparent) xrot = (0,1)^(@xang/90) yrot = (0,1)^(@yang/90) temp = 0 endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = (((2/3)*(cos(real(pz))*cos(2*imag(pz))+sqrt(2)*sin(real(pz))*cos(imag(pz)))*cos(real(pz)) \ /(sqrt(2) - sin(2*real(pz))*sin(3*imag(pz)))))*@scale2 float y = (((2/3)*(cos(real(pz))*sin(2*imag(pz))-sqrt(2)*sin(real(pz))*sin(imag(pz)))*cos(real(pz)) \ /(sqrt(2)-sin(2*real(pz))*sin(3*imag(pz)))))*@scale2 float z = ((sqrt(2)*cos(real(pz))^2 / (sqrt(2) - sin(2*real(pz))*sin(2*imag(pz)))))*@scale2 ; ; Y axis rotation ; temp = x + flip(z) temp = temp*yrot x = real(temp) z = imag(temp) ; ; X axis rotation ; temp = y + flip(z) temp = temp*xrot y = real(temp) z = imag(temp) ; calculate 3D distance float d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +z^2)*@scale if @usez if @tz == "cabs(z)" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*cabs(pz)-z)^2)*@scale elseif @tz == "real+imag z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz)+imag(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((imag(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(imag(pz))-z)^2)*@scale elseif @tz == "angle pz" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*atan2(pz)-z)^2)*@scale endif endif m_lastZ = x + flip(y) return d endfunc protected: complex xrot complex yrot complex temp default: title = "Boy Surface" heading text = "This is a 3D parametric surface." endheading int param v_BoySurface caption = "Version (Trap Shape BowSurface)" 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_BoySurface < 100 endparam float param xang caption = "X rotation" default = -20 endparam float param yang caption = "Y rotation" default = 0 endparam float param scale2 caption = "Prescale" default = 1.0 endparam float param scale caption = "Scale" default = 0.2 endparam bool param usez caption = "fractal z for z value" default = false endparam param tz caption = "fractal z type" enum = "cabs(z)" "real+imag z" "real z" "imag z" "angle pz" default = 0 visible = @usez endparam float param sz caption = "fractal z scale" default = 1 visible = @usez endparam } class REB_BourMinimalSurface(common.ulb:TrapShape) { ; This shape uses the 3D Bour Minimal Surface function.
;

public: import "common.ulb" ; Constructor func REB_BourMinimalSurface(Generic pparent) TrapShape.TrapShape(pparent) xrot = (0,1)^(@xang/90) yrot = (0,1)^(@yang/90) temp = 0 endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = ((real(pz)^(@n-1)* cos((@n-1)*imag(pz))/(2*(@n-1)) - real(pz)^(@n+1)* cos((@n+1)*imag(pz))/(2*(@n+1))))*@scale2 float y = ((real(pz)^(@n-1)* sin((@n-1)*imag(pz))/(2*(@n-1)) + real(pz)^(@n+1)* sin((@n+1)*imag(pz))/(2*(@n+1))))*@scale2 float z = ((real(pz)^@n*cos(@n*imag(pz)) / @n))*@scale2 ; ; Y axis rotation ; temp = x + flip(z) temp = temp*yrot x = real(temp) z = imag(temp) ; ; X axis rotation ; temp = y + flip(z) temp = temp*xrot y = real(temp) z = imag(temp) ; calculate 3D distance float d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +z^2)*@scale if @usez if @tz == "cabs(z)" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*cabs(pz)-z)^2)*@scale elseif @tz == "real+imag z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz)+imag(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((imag(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(imag(pz))-z)^2)*@scale elseif @tz == "angle pz" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*atan2(pz)-z)^2)*@scale endif endif m_lastZ = x + flip(y) return d endfunc protected: complex xrot complex yrot complex temp default: title = "Bour Minimal Surface" heading text = "This is a 3D parametric surface." endheading int param v_BourMinimalSurface caption = "Version (Trap Shape BourMinimalSurface)" 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_BourMinimalSurface < 100 endparam float param xang caption = "X rotation" default = -20 endparam float param yang caption = "Y rotation" default = 30 endparam float param scale2 caption = "Prescale" default = 1.0 endparam float param scale caption = "Scale" default = 0.2 endparam int param n caption = "Integer parameter" default = 3 min = 2 endparam bool param usez caption = "fractal z for z value" default = false endparam param tz caption = "fractal z type" enum = "cabs(z)" "real+imag z" "real z" "imag z" "angle pz" default = 0 visible = @usez endparam float param sz caption = "fractal z scale" default = 1 visible = @usez endparam } class REB_BohemianDome(common.ulb:TrapShape) { ; This shape uses the 3D Bohemian Dome Surface function.
;

public: import "common.ulb" ; Constructor func REB_BohemianDome(Generic pparent) TrapShape.TrapShape(pparent) xrot = (0,1)^(@xang/90) yrot = (0,1)^(@yang/90) temp = 0 endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = (@ba*cos(real(pz)))*@scale2 float y = (@bb*cos(imag(pz)) + @ba*sin(real(pz)))*@scale2 float z = (@bc*sin(imag(pz)))*@scale2 ; ; Y axis rotation ; temp = x + flip(z) temp = temp*yrot x = real(temp) z = imag(temp) ; ; X axis rotation ; temp = y + flip(z) temp = temp*xrot y = real(temp) z = imag(temp) ; calculate 3D distance float d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +z^2)*@scale if @usez if @tz == "cabs(z)" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*cabs(pz)-z)^2)*@scale elseif @tz == "real+imag z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz)+imag(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((imag(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(imag(pz))-z)^2)*@scale elseif @tz == "angle pz" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*atan2(pz)-z)^2)*@scale endif endif m_lastZ = x + flip(y) return d endfunc protected: complex xrot complex yrot complex temp default: title = "Bohemian Dome" heading text = "This is a 3D parametric surface." endheading int param v_BohemianDome caption = "Version (Trap Shape Bohemian Dome)" 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_BohemianDome < 100 endparam float param xang caption = "X rotation" default = -30 endparam float param yang caption = "Y rotation" default = 60 endparam float param scale2 caption = "Precale" default = 1.0 endparam float param scale caption = "Scale" default = 0.2 endparam float param ba caption = "param a" default = 0.5 endparam float param bb caption = "param b" default = 1.5 endparam float param bc caption = "param c" default = 1.0 endparam bool param usez caption = "fractal z for z value" default = false endparam param tz caption = "fractal z type" enum = "cabs(z)" "real+imag z" "real z" "imag z" "angle pz" default = 0 visible = @usez endparam float param sz caption = "fractal z scale" default = 1 visible = @usez endparam } class REB_BanchoffKleinBottle(common.ulb:TrapShape) { ; This shape uses the 3D Banchoff Klein Bottle Surface function.
;

public: import "common.ulb" ; Constructor func REB_BanchoffKleinBottle(Generic pparent) TrapShape.TrapShape(pparent) xrot = (0,1)^(@xang/90) yrot = (0,1)^(@yang/90) temp = 0 endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = (cos(real(pz)/@banc)*(cos(real(pz)/@banb)*(@bana+cos(imag(pz)))+ \ (sin(real(pz)/@banb)*sin(imag(pz))*cos(imag(pz)))))*@bc float y = (sin(real(pz)/@banc)*(cos(real(pz)/@banb)*(@bana+cos(imag(pz)))+ \ (sin(real(pz)/@banb)*sin(imag(pz))*cos(imag(pz)))))*@bc float z = (-sin(real(pz)/@banb)*(@bana+cos(imag(pz)))+cos(real(pz)/@banb)*sin(imag(pz))*cos(imag(pz)))*@bc ; ; Y axis rotation ; temp = x + flip(z) temp = temp*yrot x = real(temp) z = imag(temp) ; ; X axis rotation ; temp = y + flip(z) temp = temp*xrot y = real(temp) z = imag(temp) ; calculate 3D distance float d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +z^2)*@scale if @usez if @tz == "cabs(z)" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*cabs(pz)-z)^2)*@scale elseif @tz == "real+imag z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz)+imag(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((imag(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(real(pz))-z)^2)*@scale elseif @tz == "real z" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*(imag(pz))-z)^2)*@scale elseif @tz == "angle pz" d = sqrt((real(pz)-x)^2 + (imag(pz)-y)^2 +(@sz*atan2(pz)-z)^2)*@scale endif endif m_lastZ = x + flip(y) return d endfunc protected: complex xrot complex yrot complex temp default: title = "Banchoff Klein Bottle" heading text = "This is a 3D parametric surface." endheading int param v_BanchoffKleinBottle caption = "Version (Banchoff Klein Bottle)" 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_BanchoffKleinBottle < 100 endparam float param xang caption = "X rotation" default = -90 endparam float param yang caption = "Y rotation" default = 90 endparam float param scale caption = "scale" default = 0.2 endparam bool param usez caption = "fractal z for z value" default = false endparam param tz caption = "fractal z type" enum = "cabs(z)" "real+imag z" "real z" "imag z" "angle pz" default = 0 visible = @usez endparam float param sz caption = "fractal z scale" default = 1 visible = @usez endparam float param bc caption = "Banchoff scale" default = 0.5 endparam float param bana caption = "Parameter a" default = 1.414213 endparam float param banb caption = "Parameter b" default = 2.0 endparam float param banc caption = "Parameter c" default = 1.0 endparam } class REB_TrapShapeConvexPolygons(common.ulb:TrapShape) { ; This shape uses the Convex Polygons.
\$define debug public: import "common.ulb" ; Constructor func REB_TrapShapeConvexPolygons(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; call before each iteration func Init(complex pz) TrapShape.Init(pz) twopi = 2*#pi i = 0 x=0.0 y=0.0 ; create the vertex aray repeat vx[i] = sin(i*twopi/@sides) vy[i] = cos(i*twopi/@sides) v[i] = vx[i] + flip(vy[i]) i = i + 1 until i == @sides endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) i = 0 if @flavor == "flavor 1" d = 1e10 else d = 0 endif ; calculate r[i] and t[i] for first n-1 sides repeat t[i]=(5*pz/@scale-v[i])/(v[i+1]-v[i]) x=real(t[i]) y=imag(t[i]) if @extend && @flavor == "flavor 1" r[i]=abs(y) else if(x<0.0) r[i]=cabs(t[i]) elseif(x>1.0) r[i]=cabs(t[i]-1) else r[i]=abs(y) endif endif r[i]=r[i]*cabs(v[i+1]-v[i]) i = i + 1 until i == (@sides-1) ; calculate r[i] and t[i] for the last side t[@sides-1]=(5*pz/@scale-v[@sides-1])/(v[0]-v[@sides-1]) x=real(t[@sides-1]) y=imag(t[@sides-1]) if @extend && @flavor == "flavor 1" r[@sides-1]=abs(y) else if(x<0.0) r[@sides-1]=cabs(t[@sides-1]) elseif(x>1.0) r[@sides-1]=cabs(t[@sides-1]-1) else r[@sides-1]=abs(y) endif endif r[@sides-1]=r[@sides-1]*cabs(v[0]-v[@sides-1]) i = 0 repeat if r[i] < d if @flavor == "flavor 1" d = r[i] endif endif m_LastZ = m_LastZ + t[i] if @flavor == "flavor 2" d = d + cabs(r[i]) elseif @flavor == "flavor 3" d = d + cabs(t[i]) endif i = i + 1 until i == @sides m_LastZ = m_LastZ/@sides^2 if @flavor != "flavor 1" d = d/@sides^2 else d = d/@sscale endif return d endfunc private: complex v[10] complex t[10] float r[10] float vx[10] float vy[10] float twopi int i float x float y float d default: title = "Convex Polygons" int param v_ConvexPolygons caption = "Version (ConvexPolygons)" 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_ConvexPolygons < 100 endparam int param sides caption="# of sides" default = 5 min = 3 max = 10 endparam float param scale caption = "Polygon scale" default = 1.0 endparam bool param extend caption = "Extend the sides" default = false visible = @flavor == "flavor 1" endparam param flavor caption = "Poly Shape flavor" default = 0 enum = "flavor 1" "flavor 2" "flavor 3" endparam float param sscale caption = "Poly Shape scale" default = 1.0 visible = @flavor == "flavor 1" endparam } class REB_TrapShapeStars(common.ulb:TrapShape) { ; This shape uses the Convex Polygons.
\$define debug public: import "common.ulb" ; Constructor func REB_TrapShapeStars(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; call before each iteration func Init(complex pz) TrapShape.Init(pz) twopi = 2*#pi i = 0 x=0.0 y=0.0 ; create the vertex aray repeat vx[i] = sin(i*twopi/@sides) vy[i] = cos(i*twopi/@sides) v[i] = vx[i] + flip(vy[i]) i = i + 1 until i == @sides endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) i = 0 if @flavor == "flavor 1" d = 1e10 else d = 0 endif ; calculate r[i] and t[i] for first n-2 sides repeat t[i]=(5*pz/@scale-v[i])/(v[i+2]-v[i]) x=real(t[i]) y=imag(t[i]) if @extend && @flavor == "flavor 1" r[i]=abs(y) else if(x<0.0) r[i]=cabs(t[i]) elseif(x>1.0) r[i]=cabs(t[i]-1) else r[i]=abs(y) endif endif r[i]=r[i]*cabs(v[i+2]-v[i]) i = i + 1 until i == (@sides-2) ; calculate r[i] and t[i] for the last two sides t[@sides-2]=(5*pz/@scale-v[@sides-2])/(v[0]-v[@sides-2]) x=real(t[@sides-2]) y=imag(t[@sides-2]) if @extend && @flavor == "flavor 1" r[@sides-2]=abs(y) else if(x<0.0) r[@sides-2]=cabs(t[@sides-2]) elseif(x>1.0) r[@sides-2]=cabs(t[@sides-2]-1) else r[@sides-2]=abs(y) endif endif r[@sides-2]=r[@sides-2]*cabs(v[0]-v[@sides-2]) t[@sides-1]=(5*pz/@scale-v[@sides-1])/(v[1]-v[@sides-1]) x=real(t[@sides-1]) y=imag(t[@sides-1]) if @extend && @flavor == "flavor 1" r[@sides-1]=abs(y) else if(x<0.0) r[@sides-1]=cabs(t[@sides-1]) elseif(x>1.0) r[@sides-1]=cabs(t[@sides-1]-1) else r[@sides-1]=abs(y) endif endif r[@sides-1]=r[@sides-1]*cabs(v[1]-v[@sides-1]) i = 0 repeat if r[i] < d if @flavor == "flavor 1" d = r[i] endif endif m_LastZ = m_LastZ + t[i] if @flavor == "flavor 2" d = d + cabs(r[i]) elseif @flavor == "flavor 3" d = d + cabs(t[i]) endif i = i + 1 until i == @sides m_LastZ = m_LastZ/@sides^2 if @flavor != "flavor 1" d = d/@sides^2 else d = d/@sscale endif return d endfunc private: complex v[10] complex t[10] float r[10] float vx[10] float vy[10] float twopi int i float x float y float d default: title = "Stars" int param v_Stars caption = "Version (Stars)" 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_Stars < 100 endparam int param sides caption="# of sides" default = 5 min = 5 max = 10 endparam float param scale caption = "Star scale" default = 1.0 endparam bool param extend caption = "Extend the sides" default = false visible = @flavor == "flavor 1" endparam param flavor caption = "Star Shape flavor" default = 0 enum = "flavor 1" "flavor 2" "flavor 3" endparam float param sscale caption = "Star Shape scale" default = 1.0 visible = @flavor == "flavor 1" endparam } class REB_TrapShapeCircleCatacaustic(common.ulb:TrapShape) { ; This shape uses the circle catacaustic function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCircleCatacaustic(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 float af1 = 0 float af2 = 0 complex as = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif af1 = 2*@b*(1-3*2*@b*cos(theta)+2*2*@b*cos(theta)^3)/(-(1+2*(2*@b)^2)+3*2*@b*cos(theta)) af2 = 2*(2*@b)^2*sin(theta)^3/(1+2*(2*@b)^2-3*2*@b*cos(theta)) as = @a*(af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - (as)) endif m_LastZ = as return d endfunc default: title = "Circle Catacaustic" int param v_trapshapecirclecatacaustic caption = "Version (Trap Shape Circle Catacaustic)" default = 102 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_trapshapecirclecatacaustic < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeCruciform(common.ulb:TrapShape) { ; This shape uses the cruciform function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCruciform(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 float af1 = 0 float af2 = 0 complex as = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif af1 = 0.1*@a/cos(theta) af2 = 0.02*@b/sin(theta) as = (af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - (as)) endif m_LastZ = as return d endfunc default: title = "Cruciform" int param v_trapshapecruciform caption = "Version (Trap Shape Cruciform)" default = 102 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_trapshapecruciform < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeCurtateCycloid(common.ulb:TrapShape) { ; This shape uses the curtate cycloid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCurtateCycloid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 complex af1 = 0 complex af2 = 0 complex as = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif af1 = @a*theta - 0.1*@b*@afn2(theta) af2 = @a - 0.1*@b*@afn1(theta) as = (af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - (as)) endif m_LastZ = as return d endfunc default: title = "Curtate Cycloid" int param v_trapshapecurtatecycloid caption = "Version (Trap Shape Curtate Cycloid)" default = 102 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_trapshapecurtatecycloid < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam func afn1 caption = "Function #1" default = cos() endfunc func afn2 caption = "Function #2" default = sin() endfunc bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeCycloid(common.ulb:TrapShape) { ; This shape uses the cycloid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCycloid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = cabs(pz) if @absval d = abs(cabs(pz) - cabs(rr*(theta-sin(theta) + sgn*flip(rr*(1-cos(theta)))))) else d = cabs(pz - (rr*(theta-sin(theta) + sgn*flip(rr*(1-cos(theta)))))) endif m_LastZ = (rr*(theta-sin(theta) + sgn*flip(rr*(1-cos(theta))))) return d endfunc default: title = "Cycloid" int param v_trapshapecycloid caption = "Version (Trap Shape Cycloid)" default = 102 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_trapshapecycloid < 102 endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeCycloidofSeva(common.ulb:TrapShape) { ; This shape uses the cycloid of Seva function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCycloidofSeva(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.5*@a*(1+2*cos(2*theta)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Cycloid of Seva" int param v_trapshapecycloidofseva caption = "Version (Trap Shape Cycloid Of Seva)" default = 102 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_trapshapecycloidofseva < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeDeltoidCatacaustic(common.ulb:TrapShape) { ; This shape uses the deltoid catacaustic function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeDeltoidCatacaustic(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 complex af1 = 0 complex af2 = 0 complex as = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif af1 = 3*@afn1(theta) + @afn1(3*theta+#pi/2*@b) - @afn1(#pi/2*@b) af2 = 3*@afn2(theta) + @afn2(3*theta+#pi/2*@b) - @afn2(#pi/2*@b) as = 0.25*@a*(af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - (as)) endif m_LastZ = as return d endfunc default: title = "Deltoid Catacaustic" int param v_trapshapedeltoidcatacaustic caption = "Version (Trap Shape Deltoid Catacaustic)" default = 102 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_trapshapedeltoidcatacaustic < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam func afn1 caption = "Function #1" default = cos() endfunc func afn2 caption = "Function #2" default = sin() endfunc bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeDevilsCurve(common.ulb:TrapShape) { ; This shape uses the devil's curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeDevilsCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = (((0.5*@a*sin(theta))^2-(0.2*@b*cos(theta))^2)/(sin(theta)^2-cos(theta)^2))^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Devils Curve" int param v_trapshapedevilscurve caption = "Version (Trap Shape Devils Curve)" default = 102 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_trapshapedevilscurve < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeArachnida1(common.ulb:TrapShape) { ; This shape uses the arachnida 1 function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeArachnida1(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = 0 float y = 0 if @wave float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 0.25*@a*sin(@pi*theta)/sin((@pi-1)*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else x = real(pz) y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Arachnida 1" int param v_trapshapearachnida1 caption = "Version (Trap Shape Arachnida 1)" 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_trapshapearachnida1 < 101 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam int param pi caption = "Polar integer" default = 3 hint = "Affects shape and scale of trap." endparam bool param wave caption = "Add petal wave" default = false endparam float param wamp caption = "Wave amplitude" default = 0.05 visible = @wave endparam float param wfreq caption = "Wave frequency" default = 20 visible = @wave endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeArachnida2(common.ulb:TrapShape) { ; This shape uses the arachnida 2 function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeArachnida2(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) if @wave float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 0.25*@a*sin(@pi*theta)/sin((@pi+1)*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Arachnida 2" int param v_trapshapearachnida2 caption = "Version (Trap Shape Arachnida 2)" 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_trapshapearachnida2 < 101 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam int param pi caption = "Polar integer" default = 3 hint = "Affects shape and scale of trap." endparam bool param wave caption = "Add petal wave" default = false endparam float param wamp caption = "Wave amplitude" default = 0.05 visible = @wave endparam float param wfreq caption = "Wave frequency" default = 20 visible = @wave endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeArchimedes(common.ulb:TrapShape) { ; This shape uses the Archimedes function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeArchimedes(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = @b+@a*theta if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Archimedes" int param v_trapshapearchimedes caption = "Version (Trap Shape Archimedes)" default = 102 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_trapshapearchimedes < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 0.0 hint = "Affects spiral start point" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeAtzemaSpiral(common.ulb:TrapShape) { ; This shape uses the Atzema spiral function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeAtzemaSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif float af1 = 0.5*@a*(sin(theta)/theta-2*cos(theta)-theta*sin(theta)) float af2 = 0.05*@b*(cos(theta)/theta-2*sin(theta)+theta*cos(theta)) complex as = (af1 + sgn*flip(af2)) IF @absval d = abs(cabs(pz) - cabs(as)) ELSE d = cabs(pz - as) ENDIF m_LastZ = as return d endfunc default: title = "Atzema Spiral" int param v_trapshapeatzemaspiral caption = "Version (Trap Shape Atzema Spiral)" default = 102 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_trapshapeatzemaspiral < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeBicorn(common.ulb:TrapShape) { ; This shape uses the bicorn function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeBicorn(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = y^2*(@aa^2-x^2)-(x^2+2*@aa*y-@aa^2)^2+cabs(pz)*@offset else d = y^2*(@aa^2-x^2)-(x^2+2*@aa*y-@aa^2)^2+@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif float af1 = @a*sin(theta) float af2 = @a*cos(theta)^2*(2+cos(theta))/(3+sin(theta)^2) complex as = (af1 + sgn*flip(af2)) IF @absval d = abs(cabs(pz) - cabs(as)) ELSE d = cabs(pz - as) ENDIF m_LastZ = as endif return d endfunc default: title = "Bicorn" int param v_trapshapebicorn caption = "Version (Trap Shape Bicorn)" default = 102 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_trapshapebicorn < 102 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1.25 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "Bicorn parameter" default = 1.25 visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@altformula endparam bool param alttheta caption = "Alternate theta" default = false visible = !@altformula endparam } class REB_TrapShapeBicuspid(common.ulb:TrapShape) { ; This shape uses the bicuspid function.
;

; This variant of the function involves taking a square root ; so there are two solutions. A signed and absolute value version of ; the distance is also available. The transformed value is the ; complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeBicuspid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = (x^2-@aa^2)*(x-@aa)^2+(y^2-@aa^2)^2+cabs(pz)*@offset else d = (x^2-@aa^2)*(x-@aa)^2+(y^2-@aa^2)^2+@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else int sgn = 1 if @sgn sgn = -1 endif y = imag(pz) float qx = 0 float qb = -2*(0.05*@b)^2 float qc = (0.05*@b)^4 - (y^2 - (0.05*@b)^2)^2 if @negroot qx = ((-qb - (qb^2 - 4*qc)^0.5)/(2))^0.5 else qx = ((-qb + (qb^2 - 4*qc)^0.5)/(2))^0.5 endif if @absval d = abs(cabs(pz) - cabs(2.25*@a*(qx + sgn*flip(y)))) else d = cabs(pz - 2.25*@a*(qx + sgn*flip(y))) endif m_LastZ = 2.25*@a*(qx + sgn*flip(y)) endif return d endfunc default: title = "Bicuspid" int param v_trapshapebicuspid caption = "Version (Trap Shape Bicuspid)" 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_trapshapebicuspid < 101 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "parameter a" default = 1 hint = "Affects spread and scale of trap" visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@altformula endparam param negroot caption = "Quad Reg Root" default = false visible = !@altformula endparam } class REB_TrapShapeRhodonea(common.ulb:TrapShape) { ; This shape uses the rhodonea function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeRhodonea(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) if @wave float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = @a*sin(5*@b*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Rhodonea" int param v_Rhodonea caption = "Version (Rhodonea)" 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_Rhodonea < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param @wave caption = "Add petal wave" default = false endparam float param @wamp caption = "Wave amplitude" default = 0.05 visible = @wave endparam float param @wfreq caption = "Wave frequency" default = 20 visible = @wave endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeCircleTangent(common.ulb:TrapShape) { ; This shape uses the Circle Tangent function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCircleTangent(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 0.5*@a*(1+@b/10*sin(theta)^(8*@c)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Circle Tangent" int param v_CircleTangent caption = "Version (Circle Tangent)" 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_CircleTangent < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam float param c caption = "3rd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeBifolium(common.ulb:TrapShape) { ; This shape uses the bifolium function.
;

;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeFermatsSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 2*@a*theta^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Fermat's Spiral" int param v_trapshapeFermatsSpiral caption = "Version (Trap Shape Fermat's Spiral)" 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_trapshapeFermatsSpiral < 101 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeAtomSpiral(common.ulb:TrapShape) { ; This shape uses the atom spiral function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeAtomSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 0.5*@a*theta/(theta + @b*0.25) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Atom Spiral" int param v_AtomSpiral caption = "Version (Atom Spiral)" 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_AtomSpiral < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeCevasTrisectrix(common.ulb:TrapShape) { ; This shape uses the atom spiral function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCevasTrisectrix(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = (x^2+y^2)^3-((@aa+1)*x^2-(@aa-1)*y^2)^2-cabs(pz)*@offset else d = (x^2+y^2)^3-((@aa+1)*x^2-(@aa-1)*y^2)^2-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 2.5*@a*(1+@b*sin(2*theta)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else x = real(pz) y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif endif return d endfunc default: title = "Ceva's Trisectrix" int param v_CevasTrisectrix caption = "Version (Ceva's Trisectrix)" 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_CevasTrisectrix < 100 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "parameter a" default = 2 hint = "Affects spread and scale of trap" visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc bool param ptraps caption = "Use as Polar Traps" default = false visible = !@altformula endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps && !@altformula hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps && !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@ptraps && !@altformula endparam } class REB_TrapShapeHyperbolicSpiral(common.ulb:TrapShape) { ; This shape uses the HyperbolicSpiralfunction.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeHyperbolicSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = @a/theta if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Hyperbolic Spiral" int param v_HyperbolicSpiral caption = "Version (HyperbolicSpiral)" 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_HyperbolicSpiral < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeNodalCurve(common.ulb:TrapShape) { ; This shape uses the NodalCurve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeNodalCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = @a*tan(@b*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Nodal Curve" int param v_NodalCurve caption = "Version (NodalCurve)" 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_NodalCurve < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeGielisCurve(common.ulb:TrapShape) { ; This shape uses the Gielis curve.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeGielisCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) if @wave float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = @a*(abs(cos(2*@b*theta))^@pa + abs(sin(2*@b*theta))^@pb)^@pc if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Gielis Curve" int param v_GielisCurve caption = "Version (GielisCurve)" 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_GielisCurve < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam float param pa caption = "Power a" default = 10.0 hint = "Affects spread and scale of trap" endparam float param pb caption = "Power b" default = 10.0 hint = "Affects spread and scale of trap" endparam float param pc caption = "Power c" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param wave caption = "Add petal wave" default = false endparam float param wamp caption = "Wave amplitude" default = 0.05 visible = @wave endparam float param wfreq caption = "Wave frequency" default = 20 visible = @wave endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeSuperSpiral(common.ulb:TrapShape) { ; This shape uses the SuperSpiral curve.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeSuperSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) if @wave float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = @a*exp(0.2*@c*theta)*(abs(cos(3*@b*theta))^@pa + abs(sin(3*@b*theta))^@pb)^@pc if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Super Spiral" int param v_SuperSpiral caption = "Version (Super Spiral)" 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_SuperSpiral < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam float param c caption = "3rd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam float param pa caption = "Power a" default = 10.0 hint = "Affects spread and scale of trap" endparam float param pb caption = "Power b" default = 10.0 hint = "Affects spread and scale of trap" endparam float param pc caption = "Power c" default = -0.2 hint = "Affects spread and scale of trap" endparam bool param @wave caption = "Add petal wave" default = false endparam float param @wamp caption = "Wave amplitude" default = 0.05 visible = @wave endparam float param @wfreq caption = "Wave frequency" default = 20 visible = @wave endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeConchoidOfDeSluze(common.ulb:TrapShape) { ; This shape uses the ConchoidOfDeSluze function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeConchoidOfDeSluze(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale if !@cmplx x = real(@fn1(pz)) y = imag(@fn2(pz)) else x = real(@fn1(pz)) y = imag(@fn1(pz)) endif if @ref == "pz" d = x^3+x*y^2-x^2-y^2-@a1^2*x^2-cabs(pz)*@offset else d = x^3+x*y^2-x^2-y^2-@a1^2*x^2-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = @a*(1/cos(theta) - 1.5*@b*cos(theta)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif endif return d endfunc default: title = "Conchoid of De Sluze" int param v_ConchoidOfDeSluze caption = "Version (ConchoidOfDeSluze)" 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_ConchoidOfDeSluze < 100 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param a1 caption = "parameter a1" default = 2 visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam bool param cmplx caption = "Apply to complex" default = false visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula && !@cmplx endfunc bool param ptraps caption = "Use as Polar Traps" default = false visible = !@altformula endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps && !@altformula hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param b caption = "2nd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps && !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@ptraps && !@altformula endparam } class REB_TrapShapeEpitrochoid(common.ulb:TrapShape) { ; This shape uses the Epitrochoid function.
public: import "common.ulb" ; Constructor func REB_TrapShapeEpitrochoid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float t = 0 if @partype == "cabs(z)" t = cabs(pz) elseif @partype == "real(z)" t = real(pz) elseif @partype == "imag(z)" t = imag(pz) elseif @partype == "real(z) + imag(z)" t = real(pz) + imag(pz) elseif @partype == "real(z) * imag(z)" t = real(pz) * imag(pz) elseif @partype == "angle" t = atan2(pz) endif t = t*@scale float x = (@a*2.5+@b*0.6)*cos(t) - 1.3*@c*cos((2.5*@a/(@b*0.6)+1)*t) float y = (@a*2.5+@b*0.6)*sin(t) - 1.3*@c*sin((2.5*@a/(@b*0.6)+1)*t) m_LastZ = x + flip(y) d = cabs(pz-m_LastZ) return d endfunc default: title = "Epitrochoid" int param v_Epitrochoid caption = "Version (Epitrochoid)" 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_Epitrochoid < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam float param c caption = "3rd Polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam float param scale caption = "Scale" default = 1.0 endparam param partype caption = "Param Type" default = 0 enum = "cabs(z)" "real(z)" "imag(z)" "real(z) + imag(z)" "real(z) * imag(z)" \ "angle" endparam } class REB_TrapShapeCornoid(common.ulb:TrapShape) { ; This shape uses the Cornoid function.
public: import "common.ulb" ; Constructor func REB_TrapShapeInfiniteQuadrifolium(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float t = 0 if @partype == "cabs(z)" t = cabs(pz) elseif @partype == "real(z)" t = real(pz) elseif @partype == "imag(z)" t = imag(pz) elseif @partype == "real(z) + imag(z)" t = real(pz) + imag(pz) elseif @partype == "real(z) * imag(z)" t = real(pz) * imag(pz) elseif @partype == "angle" t = atan2(pz) endif t = t*@b*6.28 float x = 2*@a*(t^3-t)*(t-1)/(t^3+1)^2 float y = 2*@a*(t^3-t)*(t+1)/(t^3+1)^2 m_LastZ = x + flip(y) d = cabs(pz-m_LastZ) return d endfunc default: title = "Infinite Quadrifolium" int param v_InfiniteQuadrifolium caption = "Version (Infinite Quadrifolium)" 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_InfiniteQuadrifolium < 100 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam param partype caption = "Param Type" default = 0 enum = "cabs(z)" "real(z)" "imag(z)" "real(z) + imag(z)" "real(z) * imag(z)" \ "angle" endparam } class REB_TrapShapeLegendre(common.ulb:TrapShape) { ; This shape uses the Legendre function.
public: import "common.ulb" ; Constructor func REB_TrapShapeLegendre(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) if @wave && @partype == "angle" float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif float d = 0 float t = 0 float x = 0 float y = 0 if @partype == "cabs(z)" t = cabs(pz) elseif @partype == "real(z)" t = real(pz) elseif @partype == "imag(z)" t = imag(pz) elseif @partype == "real(z) + imag(z)" t = real(pz) + imag(pz) elseif @partype == "real(z) * imag(z)" t = real(pz) * imag(pz) elseif @partype == "angle" t = atan2(pz) endif t = t*@b if @n == "2" y = 5*@a*(3*sin(t)^2 - 1)/2 x = 5*@a*(3*cos(t)^2 - 1)/2 elseif @n == "3" y = 5*@a*(5*sin(t)^3 - 3*sin(t))/2 x = 5*@a*(5*cos(t)^3 - 3*cos(t))/2 elseif @n == "4" y = 5*@a*(35*sin(t)^4 - 30*sin(t)^2 + 3)/8 x = 5*@a*(35*cos(t)^4 - 30*cos(t)^2 + 3)/8 elseif @n == "5" y = 5*@a*(63*sin(t)^5 - 70*sin(t)^3 + 15*sin(t))/8 x = 5*@a*(63*cos(t)^5 - 70*cos(t)^3 + 15*cos(t))/8 elseif @n == "6" y = 5*@a*(231*sin(t)^6 - 315*sin(t)^4 + 105*sin(t)^2 -5)/16 x = 5*@a*(231*cos(t)^6 - 315*cos(t)^4 + 105*cos(t)^2 -5)/16 endif m_LastZ = x + flip(y) d = cabs(pz-m_LastZ) return d endfunc default: title = "Legendre" int param v_Legendre caption = "Version (Legendre)" 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_Legendre < 100 endparam param n caption = "Legendre number" default = 0 enum = "2" "3" "4" "5" "6" endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam param partype caption = "Param Type" default = 0 enum = "cabs(z)" "real(z)" "imag(z)" "real(z) + imag(z)" "real(z) * imag(z)" \ "angle" endparam bool param wave caption = "Add petal wave" default = false visible = @partype == "angle" endparam float param wamp caption = "Wave amplitude" default = 0.05 visible = @wave && @partype == "angle" endparam float param wfreq caption = "Wave frequency" default = 20 visible = @wave && @partype == "angle" endparam } class REB_TrapShapeLaguerre(common.ulb:TrapShape) { ; This shape uses the Laguerre function.
public: import "common.ulb" ; Constructor func REB_TrapShapeLaguerre(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) if @wave && @partype == "angle" float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif float d = 0 float t = 0 float x = 0 float y = 0 if @partype == "cabs(z)" t = cabs(pz) elseif @partype == "real(z)" t = real(pz) elseif @partype == "imag(z)" t = imag(pz) elseif @partype == "real(z) + imag(z)" t = real(pz) + imag(pz) elseif @partype == "real(z) * imag(z)" t = real(pz) * imag(pz) elseif @partype == "angle" t = atan2(pz) endif t = t*@b*5 if @n == "2" y = @a*(Sin(t)^2 - 4*sin(t) + 2)/2 x = @a*(cos(t)^2 - 4*cos(t) + 2)/2 elseif @n == "3" y = @a*(-sin(t)^3 + 9*sin(t)^2 - 18*sin(t) + 6)/6 x = @a*(-cos(t)^3 + 9*cos(t)^2 - 18*cos(t) + 6)/6 elseif @n == "4" y = @a*(sin(t)^4 - 16*sin(t)^3 + 72*sin(t)^2 - 96*sin(t) + 24)/24 x = @a*(cos(t)^4 - 16*cos(t)^3 + 72*cos(t)^2 - 96*cos(t) + 24)/24 elseif @n == "5" y = @a*(-sin(t)^5 + 25*sin(t)^4 - 200*sin(t)^3 + 600*sin(t)^2 - 600*sin(t) + 120)/120 x = @a*(-cos(t)^5 + 25*cos(t)^4 - 200*cos(t)^3 + 600*cos(t)^2 - 600*cos(t) + 120)/120 elseif @n == "6" y = @a*(sin(t)^6 - 36*sin(t)^5 + 450*sin(t)^4 - 2400*sin(t)^3 + 5400*sin(t)^2 \ -4320*sin(t) + 720)/720 x = @a*(cos(t)^6 - 36*cos(t)^5 + 450*cos(t)^4 - 2400*cos(t)^3 + 5400*cos(t)^2 \ -4320*cos(t) + 720)/720 endif m_LastZ = x + flip(y) d = cabs(pz-m_LastZ) return d endfunc default: title = "Laguerre" int param v_Laguerre caption = "Version (Laguerre)" 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_Laguerre < 100 endparam param n caption = "Laguerre number" default = 0 enum = "2" "3" "4" "5" "6" endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam param partype caption = "Param Type" default = 0 enum = "cabs(z)" "real(z)" "imag(z)" "real(z) + imag(z)" "real(z) * imag(z)" \ "angle" endparam bool param wave caption = "Add petal wave" default = false visible = @partype == "angle" endparam float param wamp caption = "Wave amplitude" default = 0.05 visible = @wave && @partype == "angle" endparam float param wfreq caption = "Wave frequency" default = 20 visible = @wave && @partype == "angle" endparam } class REB_TrapShapeHermite(common.ulb:TrapShape) { ; This shape uses the Hermite function.
public: import "common.ulb" ; Constructor func REB_TrapShapeHermite(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) if @wave && @partype == "angle" float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif float d = 0 float t = 0 float x = 0 float y = 0 if @partype == "cabs(z)" t = cabs(pz) elseif @partype == "real(z)" t = real(pz) elseif @partype == "imag(z)" t = imag(pz) elseif @partype == "real(z) + imag(z)" t = real(pz) + imag(pz) elseif @partype == "real(z) * imag(z)" t = real(pz) * imag(pz) elseif @partype == "angle" t = atan2(pz) endif t = t*@b if @htype == 0 if @n == "2" x = @a*(cos(t)^2 - 1) y = @a*(sin(t)^2 - 1) elseif @n == "3" x = @a*(cos(t)^3 - 3*cos(t))/3 y = @a*(sin(t)^3 - 3*sin(t))/3 elseif @n == "4" x = @a*(cos(t)^4 - 6*cos(t)^2 + 3)/3 y = @a*(sin(t)^4 - 6*sin(t)^2 + 3)/3 elseif @n == "5" x = @a*(cos(t)^5 - 10*cos(t)^3 + 15*cos(t))/15 y = @a*(sin(t)^5 - 10*sin(t)^3 + 15*sin(t))/15 elseif @n == "6" x = @a*(cos(t)^6 - 15*cos(t)^4 + 45*cos(t)^2 - 15)/15 y = @a*(sin(t)^6 - 15*sin(t)^4 + 45*sin(t)^2 - 15)/15 elseif @n == "7" x = @a*(cos(t)^7 - 21*cos(t)^5 + 105*cos(t)^3 - 105*cos(t))/105 y = @a*(sin(t)^7 - 21*sin(t)^5 + 105*sin(t)^3 - 105*sin(t))/105 elseif @n == "8" x = @a*(cos(t)^8 - 28*cos(t)^6 + 210*cos(t)^4 - 420*cos(t)^2 + 105)/105 y = @a*(sin(t)^8 - 28*sin(t)^6 + 210*sin(t)^4 - 420*sin(t)^2 + 105)/105 elseif @n == "9" x = @a*(cos(t)^9 - 36*cos(t)^7 + 378*cos(t)^5 - 1260*cos(t)^3 + 945*cos(t))/945 y = @a*(sin(t)^9 - 36*sin(t)^7 + 378*sin(t)^5 - 1260*sin(t)^3 + 945*sin(t))/945 elseif @n == "10" x = @a*(cos(t)^10 - 45*cos(t)^8 + 630*cos(t)^6 - 3150*cos(t)^4 + 4275*cos(t)^2 - 945)/945 y = @a*(sin(t)^10 - 45*sin(t)^8 + 630*sin(t)^6 - 3150*sin(t)^4 + 4275*sin(t)^2 - 945)/945 endif else if @n == "2" x = @a*4*(cos(t)^2 - 2)/2 y = @a*4*(sin(t)^2 - 2)/2 elseif @n == "3" x = @a*8*(cos(t)^3 - 12*cos(t))/144 y = @a*8*(sin(t)^3 - 12*sin(t))/144 elseif @n == "4" x = @a*16*(cos(t)^4 - 48*cos(t)^2 + 12)/288 y = @a*16*(sin(t)^4 - 48*sin(t)^2 + 12)/288 elseif @n == "5" x = @a*32*(cos(t)^5 - 160*cos(t)^3 + 120*cos(t))/2880 y = @a*32*(sin(t)^5 - 160*sin(t)^3 + 120*sin(t))/2880 elseif @n == "6" x = @a*64*(cos(t)^6 - 480*cos(t)^4 + 720*cos(t)^2 - 120)/14400 y = @a*64*(sin(t)^6 - 480*sin(t)^4 + 720*sin(t)^2 - 120)/14400 elseif @n == "7" x = @a*128*(cos(t)^7 - 1344*cos(t)^5 + 3360*cos(t)^3 - 1680*cos(t))/113000 y = @a*128*(sin(t)^7 - 1344*sin(t)^5 + 3360*sin(t)^3 - 1680*sin(t))/113000 elseif @n == "8" x = @a*256*(cos(t)^8 - 3584*cos(t)^6 + 13440*cos(t)^4 - 13440*cos(t)^2 + 1680)/564480 y = @a*256*(sin(t)^8 - 3584*sin(t)^6 + 13440*sin(t)^4 - 13440*sin(t)^2 + 1680)/564480 elseif @n == "9" x = @a*512*(cos(t)^9 - 9216*cos(t)^7 + 48384*cos(t)^5 - 80640*cos(t)^3 + 30240*cos(t))/1e7 y = @a*512*(sin(t)^9 - 9216*sin(t)^7 + 48384*sin(t)^5 - 80640*sin(t)^3 + 30240*sin(t))/1e7 elseif @n == "10" x = @a*1024*(cos(t)^10 - 23040*cos(t)^8 + 161280*cos(t)^6 - 403200*cos(t)^4 + 302400*cos(t)^2 - 20340)/1e8 y = @a*1024*(sin(t)^10 - 23040*sin(t)^8 + 161280*sin(t)^6 - 403200*sin(t)^4 + 302400*sin(t)^2 - 20340)/1e8 endif endif m_LastZ = x + flip(y) d = cabs(pz-m_LastZ) return d endfunc default: title = "Hermite" int param v_Hermite caption = "Version (Hermite)" 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_Hermite < 100 endparam param n caption = "Hermite number" default = 0 enum = "2" "3" "4" "5" "6" "7" "8" "9" "10" endparam param htype caption = "Hermite type" default = 0 enum = "probabilist" "physicist" endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam param partype caption = "Param Type" default = 0 enum = "cabs(z)" "real(z)" "imag(z)" "real(z) + imag(z)" "real(z) * imag(z)" \ "angle" endparam bool param wave caption = "Add petal wave" default = false visible = @partype == "angle" endparam float param wamp caption = "Wave amplitude" default = 0.05 visible = @wave && @partype == "angle" endparam float param wfreq caption = "Wave frequency" default = 20 visible = @wave && @partype == "angle" endparam } class REB_TrapShapeChebychev(common.ulb:TrapShape) { ; This shape uses the Chebychev function.
public: import "common.ulb" ; Constructor func REB_TrapShapeChebychev(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float t = 0 float x = 0 float y = 0 if @partype == "cabs(z)" t = cabs(pz) elseif @partype == "real(z)" t = real(pz) elseif @partype == "imag(z)" t = imag(pz) elseif @partype == "real(z) + imag(z)" t = real(pz) + imag(pz) elseif @partype == "real(z) * imag(z)" t = real(pz) * imag(pz) elseif @partype == "angle" t = atan2(pz) endif t = t*@b*5 y = @a*cos(@n*acos(sin(t))) x = @a*cos(@n*acos(cos(t))) m_LastZ = x + flip(y) d = cabs(pz-m_LastZ) return d endfunc default: title = "Chebychev" int param v_Chebychev caption = "Version (Chebychev)" 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_Chebychev < 100 endparam int param n caption = "Chebychev number" default = 2 min = 2 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam param partype caption = "Param Type" default = 0 enum = "cabs(z)" "real(z)" "imag(z)" "real(z) + imag(z)" "real(z) * imag(z)" \ "angle" endparam } class REB_TrapShapeLissajous(common.ulb:TrapShape) { ; This shape uses the Lissajous function.
public: import "common.ulb" ; Constructor func REB_TrapShapePlateauCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float t = 0 if @partype == "cabs(z)" t = cabs(pz) elseif @partype == "real(z)" t = real(pz) elseif @partype == "imag(z)" t = imag(pz) elseif @partype == "real(z) + imag(z)" t = real(pz) + imag(pz) elseif @partype == "real(z) * imag(z)" t = real(pz) * imag(pz) elseif @partype == "angle" t = atan2(pz) endif t = t*@scale float x = @a*sin((1+@b*1.2)*t)/sin((1-@b*1.2)*t) float y = @a*sin(t)*sin(@b*1.2*t)/sin((1-@b*1.2)*t) m_LastZ = x + flip(y) d = cabs(pz-m_LastZ) return d endfunc default: title = "Plateau Curve" int param v_PlateauCurve caption = "Version (PlateauCurve)" 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_PlateauCurve < 100 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam float param scale caption = "Scale" default = 1.0 endparam param partype caption = "Param Type" default = 0 enum = "cabs(z)" "real(z)" "imag(z)" "real(z) + imag(z)" "real(z) * imag(z)" \ "angle" endparam } class REB_TrapShapeEquiangularSpiral(common.ulb:TrapShape) { ; This shape uses the Equiangular Spiral function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeEquiangularSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = @a*exp(theta*cotan(@b/2)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Equiangular Spiral" int param v_EquiangularSpiral caption = "Version (Equiangular Spiral)" 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_EquiangularSpiral < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeFreethsNephroid(common.ulb:TrapShape) { ; This shape uses the bifolium function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeFreethsNephroid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 0.5*@a*(1+2*sin(theta/2)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Freeth's Nephroid" int param v_FreethsNephroid caption = "Version (FreethsNephroid)" 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_FreethsNephroid < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeSinusoidalSpiral(common.ulb:TrapShape) { ; This shape uses the Sinusoidal Spiral function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeSinusoidalSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = @a*(cos(2*@b*theta))^1/(2*@b) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Sinusoidal Spiral" int param v_SinusoidalSpiral caption = "Version (SinusoidalSpiral)" 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_SinusoidalSpiral < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeBow(common.ulb:TrapShape) { ; This shape uses the bow function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeBow(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = x^4-x^2*y+y^3-cabs(pz)*@offset else d = x^4-x^2*y+y^3-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else int sgn = 1 if @sgn sgn = -1 endif float theta = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif float af1 = 0.1*@a*(1-tan(theta)^2)*cos(theta) float af2 = 0.1*@b*(1-tan(theta)^2)*sin(theta) complex as = (af1 + sgn*flip(af2)) IF @absval d = abs(cabs(pz) - cabs(as)) ELSE d = cabs(pz - as) ENDIF m_LastZ = as endif return d endfunc default: title = "Bow" int param v_trapshapebow caption = "Version (Trap Shape Bow)" default = 102 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_trapshapebow < 102 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 0.2 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@altformula endparam bool param alttheta caption = "Alternate theta" default = false visible = !@altformula endparam } class REB_TrapShapeButterfly(common.ulb:TrapShape) { ; This shape uses the butterfly function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeButterfly(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = y^6+x^6-x^2-cabs(pz)*@offset else d = y^6+x^6-x^2-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else float theta = 0 d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = 0.25*@a*(exp(sin(theta))-2*cos(4*theta)+sin(1/24*(2*theta-#pi))) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else x = real(pz) y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif endif return d endfunc default: title = "Butterfly" int param v_trapshapebutterfly caption = "Version (Trap Shape Butterfly)" default = 102 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_trapshapebutterfly < 102 endparam heading text = "The 'Alternate formula' is a sextic polynomial form while the regular form\ is exponential and uses trigometric functions." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc bool param ptraps caption = "Use as Polar Traps" default = false visible = !@altformula endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps && !@altformula hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps && !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@ptraps && !@altformula endparam bool param alttheta caption = "Alternate theta" default = false visible = !@altformula endparam } class REB_TrapShapeCapricornoid(common.ulb:TrapShape) { ; This shape uses the Capricornoid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCapricornoid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = @aa^2*(x^4+x^2*y^2)-@ab*(x^4+y^4)-@ab*(2*x^2*y^2-2*@aa*y^3+@aa^2*y^2-2*@aa*x^2*y) -cabs(pz)*@offset else d = @aa^2*(x^4+x^2*y^2)-@ab*(x^4+y^4)-@ab*(2*x^2*y^2-2*@aa*y^3+@aa^2*y^2-2*@aa*x^2*y)-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = 0.5*@a*sin(theta)/(0.5*@b + 0.35*@c*cos(theta)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else x = real(pz) y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif endif return d endfunc default: title = "Capricornoid" int param v_Capricornoid caption = "Version (Trap Shape Capricornoid)" 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_Capricornoid < 100 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "parameter a" default = 1.5 hint = "Affects spread and scale of trap" visible = @altformula endparam float param ab caption = "parameter b" default = 3 hint = "Affects spread and scale of trap" visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc bool param ptraps caption = "Use as Polar Traps" default = false visible = !@altformula endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps && !@altformula hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param c caption = "3rd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps && !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@ptraps && !@altformula endparam bool param alttheta caption = "Alternate theta" default = false visible = !@altformula endparam } class REB_TrapShapeBulletNose(common.ulb:TrapShape) { ; This shape uses the Bullet Nose function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeBulletNose(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = @aa^2*y^2-@ab^2*x^2-x^2*y^2+cabs(pz)*@offset else d = @aa^2*y^2-@ab^2*x^2-x^2*y^2+@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else if @wave float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile x = r * cos(wtheta) y = r * sin(wtheta) pz = x + flip(y) endif float theta = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = 0.25*@a*(@b^2*sin(theta)^2-(2*@c)^2*cos(theta)^2)^0.5/(sin(theta)*cos(theta)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else x = real(pz) y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif endif return d endfunc default: title = "Bullet Nose" int param v_BulletNose caption = "Version (Trap Shape Bullet Nose)" 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_BulletNose < 100 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 0.7 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "parameter a" default = 1 visible = @altformula endparam float param ab caption = "parameter b" default = 1 visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc bool param ptraps caption = "Use as Polar Traps" default = false visible = !@altformula endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps && !@altformula hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param c caption = "3rd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param wave caption = "Add petal wave" default = false visible = !@altformula endparam float param wamp caption = "Wave amplitude" default = 0.05 visible = @wave && !@altformula endparam float param wfreq caption = "Wave frequency" default = 20 visible = @wave && !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps && !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@ptraps && !@altformula endparam bool param alttheta caption = "Alternate theta" default = false visible = !@altformula endparam } class REB_TrapShapeTrott(common.ulb:TrapShape) { public: import "common.ulb" ; Constructor func REB_TrapShapeTrott(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = 144*(x^4+y^4)-225*(x^2+y^2)+350*x^2*y^2+81-cabs(pz)*@offset else d = 144*(x^4+y^4)-225*(x^2+y^2)+350*x^2*y^2+81-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif return d endfunc default: title = "Trott" int param v_Trott caption = "Version (Trap Shape Trott)" 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_Trott < 100 endparam float param scale caption = "scale" default = 1 endparam float param width caption = "width" default = 1 endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" endparam func fn1 caption = "Function 1" default = ident() endfunc func fn2 caption = "Function 2" default = ident() endfunc } class REB_TrapShapeWattsCurve(common.ulb:TrapShape) { ; This shape uses the Watts Curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeWattsCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = @a*(1- @b*(sin(theta) + (@c-cos(theta)^2)^0.5)^2)^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Watts Curve" int param v_WattsCurve caption = "Version (Watts Curve)" 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_WattsCurve < 100 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam float param c caption = "3rd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeCardioid(common.ulb:TrapShape) { ; This shape uses the cardiod function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCardioid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = (x^2+y^2-2*@aa*x)^2-4*@aa^2*(x^2+y^2)-cabs(pz)*@offset else d = (x^2+y^2-2*@aa*x)^2-4*@aa^2*(x^2+y^2)-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = @a*(1-cos(theta)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif endif return d endfunc default: title = "Cardioid" int param v_trapshapecardioid caption = "Version (Trap Shape Cardioid)" default = 102 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_trapshapecardioid < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false visible = !@altformula endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps && !@altformula hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 0.5 visible = @altformula endparam float param width caption = "width" default = 4 visible = @altformula endparam float param aa caption = "parameter a" default = 0.75 hint = "Affects spread and scale of trap" visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps && !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@ptraps && !@altformula endparam bool param alttheta caption = "Alternate theta" default = false visible = !@altformula endparam } class REB_TrapShapeCassiniOvals(common.ulb:TrapShape) { ; This shape uses the Cassini ovals function.
;

; This variant of the function involves taking a square root ; so there are two solutions. A signed and absolute value version of ; the distance is also available. The transformed value is the ; complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCassiniOvals(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = x^4+y^4+2*x^2*y^2-2*@aa^2*x^2+2*@aa^2*y^2+@aa^4-@ab^4-cabs(pz)*@offset else d = x^4+y^4+2*x^2*y^2-2*@aa^2*x^2+2*@aa^2*y^2+@aa^4-@ab^4-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif if @negroot rr = 0.5*@a*(cos(2*theta)-((@b*0.1/(@a*0.5))^4-sin(2*theta)^2)^0.5)^0.5 else rr = 0.5*@a*(cos(2*theta)+((@b*0.1/(@a*0.5))^4-sin(2*theta)^2)^0.5)^0.5 endif if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) endif return d endfunc default: title = "Cassini Ovals" int param v_trapshapecassiniovals caption = "Version (Trap Shape Cassini Ovals)" default = 102 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_trapshapecassiniovals < 102 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "parameter a" default = 1 hint = "Affects spread and scale of trap" visible = @altformula endparam float param ab caption = "parameter b" default = 1.0 hint = "Affects spread and scale of trap" visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@altformula endparam param negroot caption = "Quad Neg Root" default = false visible = !@altformula endparam bool param alttheta caption = "Alternate theta" default = false visible = !@altformula endparam } class REB_TrapShapeCayleysSextic(common.ulb:TrapShape) { ; This shape uses the Cayley's sextic function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCayleysSextic(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = -@aa^3*x^3-48*@aa*x*(x^2+y^2)^2+64*(x^2+y^2)^3-3*@aa^2*(x^2+y^2)*(5*x^2+9*y^2)-cabs(pz)*@offset else d = -@aa^3*x^3-48*@aa*x*(x^2+y^2)^2+64*(x^2+y^2)^3-3*@aa^2*(x^2+y^2)*(5*x^2+9*y^2)-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 1.5*@a*cos(theta)^3 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif endif return d endfunc default: title = "Cayley's Sextic" int param v_trapshapecayleyssextic caption = "Version (Trap Shape Cayley's Sextic)" 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_trapshapecayleyssextic < 101 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "parameter a" default = 1 hint = "Affects spread and scale of trap" visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc bool param ptraps caption = "Use as Polar Traps" default = false visible = !@altformula endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps && !@altformula hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps && !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@ptraps && !@altformula endparam } class REB_TrapShapeCissoidofDiocles(common.ulb:TrapShape) { ; This shape uses the cissoid of Diocles function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCissoidofDiocles(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = x*(x^2+y^2)-2*@aa*y^2-cabs(pz)*@offset else d = x*(x^2+y^2)-2*@aa*y^2-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif float rr = 0.2*@a*sin(theta)*tan(theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else x = real(pz) y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif endif return d endfunc default: title = "Cissoid of Diocles" int param v_trapshapecissoidofdiocles caption = "Version (Trap Shape Cissoid Of Diocles)" 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_trapshapecissoidofdiocles < 101 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 1 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "parameter a" default = 1 hint = "Affects spread and scale of trap" visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc bool param ptraps caption = "Use as Polar Traps" default = false visible = !@altformula endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps && !@altformula hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps && !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@ptraps && !@altformula endparam } class REB_TrapShapeCochleoid(common.ulb:TrapShape) { ; This shape uses the cochleoid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCochleoid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = 1.25*@a*sin(theta)/theta if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Cochleoid" int param v_trapshapecochleoid caption = "Version (Trap Shape Cochleoid)" default = 102 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_trapshapecochleoid < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeHeartCurve(common.ulb:TrapShape) { ; This shape uses the Heart Curve function.
public: import "common.ulb" ; Constructor func REB_TrapShapeHeartCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float t = (7.5*@a*atan2(pz))%1 float x = 0.33*@b*sin(t)*cos(t)*log(abs(t)) float y = 0.33*@b*abs(t)^0.3*cos(t)^0.5 m_lastZ = x + flip(y) d = cabs(pz-m_lastZ) return d endfunc default: title = "Heart Curve" int param v_HeartCurve caption = "Version (HeartCurve)" 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_HeartCurve < 100 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam } class REB_TrapShapeAtriphtaloid(common.ulb:TrapShape) { ; This shape uses the Atriphtaloid function.
public: import "common.ulb" ; Constructor func REB_TrapShapeAtriphtaloid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = x^4*(x^2+y^2)-(@ps*@aa*x^2-@ps*@ab)^2+cabs(pz)*@offset else d = x^4*(x^2+y^2)-(@ps*@aa*x^2-@ps*@ab)^2+@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else x = real(pz) y = (-x^2+(100*@b)^2-100*@b*@c/x^2+ (0.5*@c)^2/x^4)^0.5 m_lastZ = 0.005*@a*(x + flip(y)) d = cabs(pz-m_lastZ) endif return d endfunc default: title = "Atriphtaloid" int param v_Atriphtaloid caption = "Version (Atriphtaloid)" 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_Atriphtaloid < 100 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 0.2 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param aa caption = "parameter a" default = 5 hint = "Affects spread and scale of trap" visible = @altformula endparam float param ab caption = "parameter b" default = 1.0 hint = "Affects spread and scale of trap" visible = @altformula endparam float param ps caption = "param scaler" default = 0.4 hint = "Affects spread and scale of trap" visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam float param c caption = "3rd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" visible = !@altformula endparam } class REB_TrapShapeBurnsideCurve(common.ulb:TrapShape) { ; This shape uses the Burnside Curve function.
public: import "common.ulb" ; Constructor func REB_TrapShapeBurnsideCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula pz = pz/@scale ; pz = pz*(cos(rotangle)+flip(sin(rotangle))) x = real(@fn1(pz)) y = imag(@fn2(pz)) if @ref == "pz" d = y^2-x*(x^4-@a1)-cabs(pz)*@offset else d = y^2-x*(x^4-@a1)-@offset endif if abs(d) < @width d =abs(d) else d = 1e20 endif else x = real(pz) y = (x^5 - x)^0.5 m_lastZ = 2*@a*(x + flip(y)) d = cabs(pz-m_lastZ) endif return d endfunc default: title = "Burnside Curve" int param v_BurnsideCurve caption = "Version (BurnsideCurve)" 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_BurnsideCurve < 100 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param scale caption = "scale" default = 0.25 visible = @altformula endparam float param width caption = "width" default = 1 visible = @altformula endparam float param a1 caption = "parameter a" default = 1 visible = @altformula endparam param ref caption = "offset reference" default = 0 enum = "zero" "pz" visible = @altformula endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam } class REB_TrapShapeKleinQuartic(common.ulb:TrapShape) { ; This shape uses the KleinQuartic function.
public: import "common.ulb" ; Constructor func REB_TrapShapeKleinQuartic(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float x = real(pz) float y = (-x/2+(x^2/4+x^9/27)^0.5)^(1/3)+(-x/2-(x^2/4+x^9/27)^0.5)^(1/3) m_lastZ = @a*(x + flip(y)) float d = cabs(pz-m_lastZ) return d endfunc default: title = "Klein Quartic" int param v_KleinQuartic caption = "Version (Klein Quartic)" 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_KleinQuartic < 100 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam } class REB_TrapShapeTrochoid(common.ulb:TrapShape) { ; This shape uses the Trochoid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeTrochoid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float theta = atan2(pz) float x = @a*(@b*theta-@c*sin(theta)) float y = @a*(@b-@c*cos(theta)) m_lastZ = x + flip(y) d = cabs(pz-m_lastZ) return d endfunc default: title = "Trochoid" int param v_Trochoid caption = "Version (Trochoid)" 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_Trochoid < 100 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam float param c caption = "3rd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam } class REB_TrapShapeFishCurve(common.ulb:TrapShape) { ; This shape uses the Heart Curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeFishCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float t = 5*@a*atan2(pz) float x = @b*(cos(t) - sin(t)^2/sqrt(2)) float y = @b*cos(t)*sin(t) m_lastZ = x + flip(y) d = cabs(pz-m_lastZ) return d endfunc default: title = "Fish Curve" int param v_FishCurve caption = "Version (FishCurve)" 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_FishCurve < 100 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam } class REB_TrapShapeConchoid(common.ulb:TrapShape) { ; This shape uses the conchoid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeConchoid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = 0.1*(@a + @b*cos(theta))/cos(theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Conchoid" int param v_trapshapeconchoid caption = "Version (Trap Shape Conchoid)" default = 102 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_trapshapeconchoid < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeCotesSpiral(common.ulb:TrapShape) { ; This shape uses the Cote's spiral function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeCotesSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif float rr = @a/cosh(@b*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Cotes' Spiral" int param v_trapshapecotesspiral caption = "Version (Trap Shape Cotes' Spiral)" default = 102 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_trapshapecotesspiral < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeDiamond(common.ulb:TrapShape) { ; This shape uses the diamond function.
;

;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeDipoleCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a*(cos(theta))^2 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Dipole Curve" int param v_trapshapedipolecurve caption = "Version (Trap Shape Dipole Curve)" default = 102 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_trapshapedipolecurve < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeDumbellCurve(common.ulb:TrapShape) { ; This shape uses the dumbell function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeDumbellCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float cx = 0 float cy = 0 float d = 0 cx = real(pz) cy = (cx^4-cx^6)^0.5 if @absval d = abs(cabs(pz) - cabs(4*@a*(cx + sgn*flip(cy)))) else d = cabs(pz - 4*@a*(cx + sgn*flip(cy))) endif m_LastZ = 4*@a*(cx + sgn*flip(cy)) return d endfunc default: title = "Dumbell Curve" int param v_trapshapedumbellcurve caption = "Version (Trap Shape Dumbell Curve)" 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_trapshapedumbellcurve < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam } class REB_TrapShapeEightCurve(common.ulb:TrapShape) { ; This shape uses the eight function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeEightCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a*cos(theta)^(-2)*cos(2*theta)^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Eight Curve" int param v_trapshapeeightcurve caption = "Version (Trap Shape Eight Curve)" default = 102 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_trapshapeeightcurve < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeEllipseCatacaustic(common.ulb:TrapShape) { ; This shape uses the ellipse catacaustic function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeEllipseCatacaustic(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif complex af1 = 4*@a*(@a-@b)*(@a*@b)*sin(theta)^3/(@a^2+@b^2+(@b^2-@a^2)*cos(2*theta)) complex af2 = 4*@b*(@b^2-@a^2)*cos(theta)^3/(@a^2+@b^2+3*(@b^2-@a^2)*cos(2*theta)) complex as = 0.1*(af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - as) endif m_LastZ = as return d endfunc default: title = "Ellipse Catacaustic" int param v_trapshapeellipsecatacaustic caption = "Version (Trap Shape Ellipse Catacaustic)" default = 102 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_trapshapeellipsecatacaustic < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeEllipseEvolute(common.ulb:TrapShape) { ; This shape uses the ellipse evolute function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeEllipseEvolute(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif complex af1 = (@a^2-(0.7*@b)^2)/@a*@afn1(theta)^(real(@pwr)) complex af2 = ((0.7*@b)^2-@a^2)/(0.7*@b)*@afn2(theta)^(imag(@pwr)) complex as = 0.1*(af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - as) endif m_LastZ = as return d endfunc default: title = "Ellipse Evolute" int param v_trapshapeellipseevolute caption = "Version (Trap Shape Ellipse Evolute)" default = 102 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_trapshapeellipseevolute < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam complex param pwr caption = "Power" default = (3,3) hint = "Affects shape and scale of trap." endparam func afn1 caption = "Function #1" default = cos() endfunc func afn2 caption = "Function #2" default = sin() endfunc bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeEpicycloid(common.ulb:TrapShape) { ; This shape uses the epicycloid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeEpicycloid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif complex af1 = (5*@a+@b)*@afn1(theta) - @b*@afn1((5*@a+@b)*theta/@b) complex af2 = (5*@a+@b)*@afn2(theta) - @b*@afn2((5*@a+@b)*theta/@b) complex as = 0.1*(af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - as) endif m_LastZ = as return d endfunc default: title = "Epicycloid" int param v_trapshapeepicycloid caption = "Version (Trap Shape Epicycloid)" default = 102 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_trapshapeepicycloid < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam func afn1 caption = "Function #1" default = cos() endfunc func afn2 caption = "Function #2" default = sin() endfunc bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeEpispiral(common.ulb:TrapShape) { ; This shape uses the epispiral function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeEpispiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif rr = 0.25*@a/cos(@pn*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Epispiral" int param v_trapshapeepispiral caption = "Version (Trap Shape Epispiral)" 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_trapshapeepispiral < 101 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam int param pn caption = "Polar integer" default = 3 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeFoliumOfDescartes(common.ulb:TrapShape) { ; This shape uses the folium of Descartes function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeFoliumOfDescartes(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif rr = 0.3*@a*tan(theta)/(cos(theta)*(1+tan(theta)^3)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Folium Of Descartes" int param v_trapshapefoliumofdescartes caption = "Version (Trap Shape Folium Of Descartes)" 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_trapshapefoliumofdescartes < 101 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeGearCurve(common.ulb:TrapShape) { ; This shape uses the gear curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeGearCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) if @wave float r = cabs(pz) float wtheta = atan2(pz) if wtheta < 0 wtheta = wtheta + 2 * #pi endif int iter = 0 while iter < 2 wtheta = wtheta + @wamp * cos(@wfreq * r) iter = iter + 1 endwhile float x = r * cos(wtheta) float y = r * sin(wtheta) pz = x + flip(y) endif int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif complex af1 = (0.25*@a+1/(5*@b)*tanh(5*@b*sin(@pn*theta)))*cos(theta) complex af2 = (0.25*@a+1/(5*@b)*tanh(5*@b*sin(@pn*theta)))*sin(theta) complex as = (af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - as) endif m_LastZ = as return d endfunc default: title = "Gear Curve" int param v_trapshapegearcurve caption = "Version (Trap Shape Gear Curve)" default = 102 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_trapshapegearcurve < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam int param pn caption = "Polar integer" default = 3 hint = "Affects spread and scale of trap" endparam bool param wave caption = "Add petal wave" default = false endparam float param wamp caption = "Wave amplitude" default = 0.05 visible = @wave endparam float param wfreq caption = "Wave frequency" default = 20 visible = @wave endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeHipopede(common.ulb:TrapShape) { ; This shape uses the hipopede function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeHipopede(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = (0.5*@b*(0.5*@a-(0.5*@b)^2*cos(theta)))^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Hipopede" int param v_trapshapehipopede caption = "Version (Trap Shape Hipopede)" default = 102 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_trapshapehipopede < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeHyperbola(common.ulb:TrapShape) { public: import "common.ulb" ; Constructor func REB_TrapShapeHyperbola(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.35*@a*(1/cos(2*theta))^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Hyperbola REB" int param v_trapshapehyperbolareb caption = "Version (Trap Shape Hyperbola REB)" default = 102 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_trapshapehyperbolareb < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeKampyleofEudoxus(common.ulb:TrapShape) { ; This shape uses the kampyle of Eudoxus function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeKampyleofEudoxus(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.02*@a/cos(theta)^2 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Kampyle of Eudoxus" int param v_trapshapekampyleofeudoxus caption = "Version (Trap Shape Kampyle Of Eudoxus)" default = 102 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_trapshapekampyleofeudoxus < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeKappaCurve(common.ulb:TrapShape) { ; This shape uses the kapp a curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeKappaCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.1*@a*tan(theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Kappa Curve" int param v_trapshapekappacurve caption = "Version (Trap Shape Kappa Curve)" default = 102 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_trapshapekappacurve < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeKeratoidCusp(common.ulb:TrapShape) { ; This shape uses the keratoid cusp function.
;

; This variant of the function involves taking a square root ; so there are two solutions. A signed and absolute value version of ; the distance is also available. The transformed value is the ; complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeKeratoidCusp(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float d = 0 complex cx = real(pz) complex qa = 1 complex qb = -cx^2 complex qc = -cx^5 if @negroot == true qy = (-qb - (qb^2 - 4*qa*qc)^0.5)/(2*qa) else qy = (-qb + (qb^2 - 4*qa*qc)^0.5)/(2*qa) endif if @absval == true d = abs(cabs(pz) - cabs(2.5*@a*(cx + sgn*flip(qy)))) else d = cabs(pz - 2.5*@a*(cx + sgn*flip(qy))) endif m_LastZ = 2.5*@a*(cx + sgn*flip(qy)) return d endfunc default: title = "Keratoid Cusp" int param v_trapshapekeratoidcusp caption = "Version (Trap Shape Keratoid Cusp)" 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_trapshapekeratoidcusp < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam param negroot caption = "Quad Neg Root" default = true endparam } class REB_TrapShapeKnotCurve(common.ulb:TrapShape) { ; This shape uses the knot curve function.
;

; This variant of the function involves taking a square root ; so there are two solutions. A signed and absolute value version of ; the distance is also available. The transformed value is the ; complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeKnotCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float x = 0 float y = 0 if @altformula x = real(@fn1(pz)) y = imag(@fn2(pz)) d = (x^2-1)^2-y^2*(2*y+3)+@offset d = abs(d) else int sgn = 1 if @sgn sgn = -1 endif complex cy = imag(pz) complex qx = 0 complex qa = 1 complex qb = -2 complex qc = 1 - 3*cy^2 - 2*cy^3 if @negroot == true qx = ((-qb - (qb^2 - 4*qa*qc)^0.5)/(2*qa))^0.5 else qx = ((-qb + (qb^2 - 4*qa*qc)^0.5)/(2*qa))^0.5 endif if @absval == true d = abs(cabs(pz) - cabs(@a*(qx + sgn*flip(cy)))) else d = cabs(pz - @a*(qx + sgn*flip(cy))) endif m_LastZ = @a*(qx + sgn*flip(cy)) endif return d endfunc default: title = "KnotCurve" int param v_trapshapeknotcurve caption = "Version (Trap Shape Knot Curve)" 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_trapshapeknotcurve < 101 endparam heading text = "The 'Alternate formula' is a polynomial form which may give a more \ accurate rendering of the trap shape." endheading bool param altformula caption = "Alternate formula" default = false endparam float param offset caption = "Offset" default = 0.0 hint = "Trap offset" visible = @altformula endparam func fn1 caption = "Function 1" default = ident() visible = @altformula endfunc func fn2 caption = "Function 2" default = ident() visible = @altformula endfunc float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" visible = !@altformula endparam bool param sgn caption = "Conjugate transform" default = false visible = !@altformula endparam param absval caption = "Absolute Value" default = false visible = !@altformula endparam param negroot caption = "Quad Neg Root" default = true visible = !@altformula endparam } class REB_TrapShapeLemniscate(common.ulb:TrapShape) { ; This shape uses the lemniscate function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeLemniscate(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a*(cos(2*theta))^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Lemniscate" int param v_trapshapelemniscate caption = "Version (Trap Shape Lemniscate)" default = 102 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_trapshapelemniscate < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeArcsOfSamothrace(common.ulb:TrapShape) { ; This shape uses the lemniscate function.
;

;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeLimaconOfPascal(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.05*@b + @a*cos(theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Limacon Of Pascal" int param v_trapshapelimaconofpascal caption = "Version (Trap Shape Limacon Of Pascal)" default = 102 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_trapshapelimaconofpascal < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeLine(common.ulb:TrapShape) { ; This shape uses the ophiuride function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeLine(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 int sgn = 1 if @sgn sgn = -1 endif float cx = real(pz) float cy = cx if @absval d = abs(cabs(pz) - cabs(3*@a*(cx + sgn*flip(cy)))) else d = cabs(pz - 3*@a*(cx + sgn*flip(cy))) endif m_LastZ = 3*@a*(cx + sgn*flip(cy)) return d endfunc default: title = "Line" int param v_trapshapeline caption = "Version (Trap Shape Line)" 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_trapshapeline < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam } class REB_TrapShapeLinksCurve(common.ulb:TrapShape) { ; This shape uses the links curve function.
;

; This variant of the function involves taking a square root ; so there are two solutions. A signed and absolute value version of ; the distance is also available. The transformed value is the ; complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeLinksCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 int sgn = 1 if @sgn sgn = -1 endif float cx = real(pz) float qa = 1 float qb = 2*cx^2-6*cx float qc = cx^4-2*cx^3+cx^2 if @negroot qy = ((-qb - (qb^2 - 4*qa*qc)^0.5)/(2*qa))^0.5 else qy = ((-qb + (qb^2 - 4*qa*qc)^0.5)/(2*qa))^0.5 endif if @absval d = abs(cabs(pz) - cabs(@a*(cx + sgn*flip(qy)))) else d = cabs(pz - @a*(cx + sgn*flip(qy))) endif m_LastZ = @a*(cx + sgn*flip(qy)) return d endfunc default: title = "Links Curve" int param v_trapshapelinkscurve caption = "Version (Trap Shape Links Curve)" 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_trapshapelinkscurve < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam param negroot caption = "Quad Neg Root" default = true endparam } class REB_TrapShapeLituus(common.ulb:TrapShape) { ; This shape uses the lituus function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeLituus(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.25*@a/theta^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Lituus" int param v_trapshapelituus caption = "Version (Trap Shape Lituus)" default = 102 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_trapshapelituus < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeLogSpiral(common.ulb:TrapShape) { ; This shape uses the log spiral function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeLogSpiral(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = exp(@a*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Log Spiral" int param v_trapshapelogspiral caption = "Version (Trap Shape Log Spiral)" default = 102 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_trapshapelogspiral < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeLogSpiralCatacaustic(common.ulb:TrapShape) { ; This shape uses the log spiral catacaustic function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeLogSpiralCatacaustic(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) int sgn = 1 if @sgn sgn = -1 endif float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif complex af1 = 0.2*@b*exp(0.1*@b*theta)*(0.1*@b*cos(theta)-sin(theta))/(1+(0.1*@b)^2) complex af2 = 0.2*@b*exp(0.1*@b*theta)*(0.1*@b*cos(theta)+sin(theta))/(1+(0.1*@b)^2) complex as = @a*(af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - as) endif m_LastZ = as return d endfunc default: title = "Log Spiral Catacaustic" int param v_trapshapelogspiralcatacaustic caption = "Version (Trap Shape Log Spiral Catacaustic)" default = 102 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_trapshapelogspiralcatacaustic < 102 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeMalteseCross(common.ulb:TrapShape) { public: import "common.ulb" ; Constructor func REB_TrapShapeMalteseCross(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.2*@a/(cos(theta)*sin(theta)*(cos(theta)^2-sin(theta)^2))^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Maltese Cross" int param v_trapshapemaltesecross caption = "Version (Trap Shape Maltese Cross)" default = 102 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_trapshapemaltesecross < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeNephroid(common.ulb:TrapShape) { ; This shape uses the nephroid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeNephroid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif complex af1 = 3*@afn1(theta) - @afn1(theta/3) complex af2 = 3*@afn2(theta) - @afn2(theta/3) complex as = 0.5*@a*(af1+sgn*flip(af2)) m_LastZ = as if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - (as)) endif return d endfunc default: title = "Nephroid" int param v_trapshapenephroid caption = "Version (Trap Shape Nephroid)" default = 102 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_trapshapenephroid < 102 endparam float param a caption = "Polar Parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam func afn1 caption = "Function #1" default = cos() endfunc func afn2 caption = "Function #2" default = sin() endfunc bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeParabola(common.ulb:TrapShape) { ; This shape uses the parabola function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeParabola(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 int sgn = 1 if @sgn sgn = -1 endif float cy = imag(pz) float cx = 10*@b*cy^2 m_LastZ = 0.65*@a*(cx + sgn*flip(cy)) if @absval d = abs(cabs(pz) - cabs(0.65*@a*(cx + sgn*flip(cy)))) else d = cabs(pz - 0.65*@a*(cx + sgn*flip(cy))) endif return d endfunc default: title = "Parabola" int param v_trapshapeparabola caption = "Version (Trap Shape Parabola)" 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_trapshapeparabola < 101 endparam float param a caption = "Polar Parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar Parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam } class REB_TrapShapeTridentOfNewton(common.ulb:TrapShape) { ; This shape uses the Trident Of Newton function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeTridentOfNewton(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 int sgn = 1 if @sgn sgn = -1 endif float cx = real(pz) float cy = cx^2 + @b*cx - @c + 0.02*@d/cx m_LastZ = @a*(cx + sgn*flip(cy)) if @absval d = abs(cabs(pz) - cabs(m_LastZ)) else d = cabs(pz - m_LastZ) endif return d endfunc default: title = "Trident Of Newton" int param v_TridentOfNewton caption = "Version (Trident Of Newton)" 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_TridentOfNewton < 100 endparam float param a caption = "Polar Parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar Parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam float param c caption = "3rd Polar Parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam float param d caption = "4th Polar Parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam } class REB_TrapShapeWassenaarCurve(common.ulb:TrapShape) { ; This shape uses the Wassenaar Curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeWassenaarCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 int sgn = 1 if @sgn sgn = -1 endif complex cx = real(pz) complex cy = 0 if @negroot cy = cx^2 - (1-30*@b*cx^2)^0.5 else cy = cx^2 + (1-30*@b*cx^2)^0.5 endif m_LastZ = @a*(cx + sgn*flip(cy)) if @absval d = abs(cabs(pz) - cabs(m_LastZ)) else d = cabs(pz - m_LastZ) endif return d endfunc default: title = "Wassenaar Curve" int param v_WassenaarCurve caption = "Version (Wassenaar Curve)" 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_WassenaarCurve < 100 endparam float param a caption = "Polar Parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar Parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam param negroot caption = "Quad Neg Root" default = false endparam } class REB_TrapShapeWeibullCurve(common.ulb:TrapShape) { ; This shape uses the Weibull Curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeWeibullCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 int sgn = 1 if @sgn sgn = -1 endif complex cx = real(pz) complex cy = exp(-cx^(@b/10)) m_LastZ = @a*(cx + sgn*flip(cy)) if @absval d = abs(cabs(pz) - cabs(m_LastZ)) else d = cabs(pz - m_LastZ) endif return d endfunc default: title = "Weibull Curve" int param v_WeibullCurve caption = "Version (Weibull Curve)" 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_WeibullCurve < 100 endparam float param a caption = "Polar Parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar Parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam } class REB_TrapShapePiriform(common.ulb:TrapShape) { ; This shape uses the piriform function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapePiriform(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 float theta = 0 int sgn = 1 if @sgn sgn = -1 endif if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif complex af1 = 0.1*@a*(1+sin(theta)) complex af2 = 0.1*@b*cos(theta)*(1+sin(theta)) complex as = (af1 + sgn*flip(af2)) m_LastZ = as if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - as) endif return d endfunc default: title = "Piriform" int param v_trapshapepiriform caption = "Version (Trap Shape Piriform)" default = 102 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_trapshapepiriform < 102 endparam float param a caption = "Polar Parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar Parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapePoinsotSpiral1(common.ulb:TrapShape) { ; This shape uses the Poinsot spiral 1 function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapePoinsotSpiral1(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a/cosh(@pn*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Poinsot Spiral 1" int param v_trapshapepoinsotspiral1 caption = "Version (Trap Shape Poinsot Spiral 1)" default = 102 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_trapshapepoinsotspiral1 < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam int param pn caption = "Polar integer" default = 3 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapePoinsotSpiral2(common.ulb:TrapShape) { ; This shape uses the Poinsot spiral 2 function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapePoinsotSpiral2(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a/sinh(@pn*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Poinsot Spiral 2" int param v_trapshapepoinsotspiral2 caption = "Version (Trap Shape Poinsot Spiral 2)" default = 102 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_trapshapepoinsotspiral2 < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam int param pn caption = "Polar integer" default = 3 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapePolytrope(common.ulb:TrapShape) { ; This shape uses the polytrope function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapePolytrope(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 int sgn = 1 if @sgn sgn = -1 endif float cx = real(pz) float cy = 1/cx^@pn if @absval d = abs(cabs(pz) - cabs(0.00005*@a*(cx + sgn*flip(cy)))) else d = cabs(pz - 0.00005*@a*(cx + sgn*flip(cy))) endif m_LastZ = 0.00005*@a*(cx + sgn*flip(cy)) return d endfunc default: title = "Polytrope" int param v_trapshapepolytrope caption = "Version (Trap Shape Polytrope)" 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_trapshapepolytrope < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam int param pn caption = "Polar integer" default = 3 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam } class REB_TrapShapeQuadratrixOfHippias(common.ulb:TrapShape) { ; This shape uses the quadratrix of Hippias function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeQuadratrixOfHippias(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a*theta/sin(theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Quadratrix of Hippias" int param v_trapshapequadratrixofhippias caption = "Version (Trap Shape Quadratrix Of Hippias)" default = 102 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_trapshapequadratrixofhippias < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeQuadrifolium(common.ulb:TrapShape) { ; This shape uses the quadrifolium function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeQuadrifolium(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a*sin(2*theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Quadrifolium" int param v_trapshapequadrifolium caption = "Version (Trap Shape Quadrifolium)" default = 102 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_trapshapequadrifolium < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeRose(common.ulb:TrapShape) { ; This shape uses the rose function.
;

;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeRoseOfTroy(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @c*(1+10*@a*sin(4*@b*theta)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Rose of Troy" int param v_trapshaperoseoftroy caption = "Version (Trap Shape Rose Of Troy)" default = 102 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_trapshaperoseoftroy < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam float param c caption = "3rd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeScarabaeus(common.ulb:TrapShape) { ; This shape uses the scarabaeus function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeScarabaeus(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.25*@b*cos(2*theta)-0.5*@a*cos(theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Scarabaeus" int param v_trapshapescarabaeus caption = "Version (Trap Shape Scarabaeus)" default = 102 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_trapshapescarabaeus < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeSemicubicalParabola(common.ulb:TrapShape) { ; This shape uses the semicubical parabola function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeSemicubicalParabola(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = @a*(cos(2*@b*theta))^(1/(2*@b)) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Semicubical Parabola" int param v_trapshapesemicubicalparabola caption = "Version (Trap Shape Semicubical Parabola)" default = 102 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_trapshapesemicubicalparabola < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeSerpentineCurve(common.ulb:TrapShape) { ; This shape uses the serpentine curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeSerpentineCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif complex af1 = 0.2*@a*cotan(theta) complex af2 = 0.2*@b*sin(theta)*cos(theta) complex as = (af1 + sgn*flip(af2)) if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - as) endif m_LastZ = pz - as return d endfunc default: title = "Serpentine Curve" int param v_trapshapeserpentinecurve caption = "Version (Trap Shape Serpentine Curve)" 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_trapshapeserpentinecurve < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam } class REB_TrapShapeStirrupCurve(common.ulb:TrapShape) { ; This shape uses the stirrup curve function.
;

; This variant of the function involves taking a square root ; so there are two solutions. A signed and absolute value version of ; the distance is also available. The transformed value is the ; complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeStirrupCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float d = 0 int sgn = 1 if @sgn sgn = -1 endif float cy = imag(pz) float qa = 1 float qb = -2 float qc = 1-cy^2*(cy-1)*(cy-2)*(cy+5) float qx = 0 if @negroot qx = ((-qb - (qb^2 - 4*qa*qc)^0.5)/(2*qa))^0.5 else qx = ((-qb + (qb^2 - 4*qa*qc)^0.5)/(2*qa))^0.5 endif if @absval d = abs(cabs(pz) - cabs(@a*(qx + sgn*flip(cy)))) else d = cabs(pz - @a*(qx + sgn*flip(cy))) endif m_LastZ = @a*(qx + sgn*flip(cy)) return d endfunc default: title = "Stirrup Curve" int param v_trapshapestirrupcurve caption = "Version (Trap Shape Stirrup Curve)" 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_trapshapestirrupcurve < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false endparam param absval caption = "Absolute Value" default = false endparam param negroot caption = "Quad Neg Root" default = true endparam } class REB_TrapShapeStrophoid(common.ulb:TrapShape) { ; This shape uses the strophoid function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeStrophoid(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 theta = atan2(pz) int sgn = 1 if @sgn sgn = -1 endif rr = 0.1*@b*sin(@a-2*theta)/sin(@a-theta) if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Strophoid" int param v_trapshapestrophoid caption = "Version (Trap Shape Strophoid)" 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_trapshapestrophoid < 101 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float param b caption = "2nd Polar parameter" default = 1.0 hint = "Affects shape and scale of trap." endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam } class REB_TrapShapeSwastikaCurve(common.ulb:TrapShape) { ; This shape uses the swastika curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate and a ; polar variant. The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeSwastikaCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 float rr = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif rr = 0.25*@a*(sin(theta)*cos(theta)/(sin(theta)^4-cos(theta)^4))^0.5 if !@ptraps if @absval d = abs(cabs(pz) - cabs(rr*cos(theta)+ sgn*flip(rr*sin(theta)))) else d = cabs(pz - (rr*cos(theta) + sgn*flip(rr*sin(theta)))) endif m_LastZ = (rr*cos(theta) + sgn*flip(rr*sin(theta))) else float x = real(pz) float y = imag(pz) if @disttype == 0 d = abs(x-rr*cos(theta) + y-rr*sin(theta)) else d = (abs(x-rr*cos(theta)) + abs(y-rr*sin(theta))) endif m_LastZ = x-rr*cos(theta) + flip(y-rr*sin(theta)) endif return d endfunc default: title = "Swastika Curve" int param v_trapshapeswastikacurve caption = "Version (Trap Shape Swastika Curve)" default = 102 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_trapshapeswastikacurve < 102 endparam bool param ptraps caption = "Use as Polar Traps" default = false endparam param disttype caption = "Distance type" default = 0 enum = "Abs total" "Abs parts" visible = @ptraps hint = "The distance function must be positive. \ The absolute value can be taken of the \ whole function or of its individual parts." endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam bool param sgn caption = "Conjugate transform" default = false visible = !@ptraps endparam param absval caption = "Absolute Value" default = false visible = !@ptraps endparam bool param alttheta caption = "Alternate theta" default = false endparam } class REB_TrapShapeTeardropCurve(common.ulb:TrapShape) { ; This shape uses the teardrop curve function.
;

; This variant of the function has a signed and absolute value ; version of the distance. The function also has a complex conjugate variant. ; The transformed value is the complex return value of the function. public: import "common.ulb" ; Constructor func REB_TrapShapeTeardropCurve(Generic pparent) TrapShape.TrapShape(pparent) endfunc ; Call this for each iteration being trapped. float func Iterate(complex pz) TrapShape.Iterate(pz) float theta = 0 float d = 0 if !@alttheta theta = atan2(pz) else theta = atan(imag(pz)/real(pz)) endif int sgn = 1 if @sgn sgn = -1 endif complex af1 = @a*cos(theta) complex af2 = 0.5*@b*sin(theta)*sin(theta/2)^(@pn-1) complex as = (af1 + sgn*flip(af2)) m_LastZ = as if @absval d = abs(cabs(pz) - cabs(as)) else d = cabs(pz - (as)) endif return d endfunc default: title = "Teardrop Curve" int param v_trapshapeteardropcurve caption = "Version (Trap Shape Teardrop Curve)" 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_trapshapeteardropcurve < 101 endparam float param a caption = "Polar parameter" default = 0.2 hint = "Affects spread and scale of trap" endparam float par