Class InvertDodecahedron(InvertSphere) {
; sphere inversions starting with a dodecahedral geometery <br>
; this is a child of InvertSphere
public:
import "common.ulb"
; constructor for sphere inversions with a dodecahedral geometry
func InvertDodecahedron(Generic pparent)
InvertSphere.InvertSphere(0)
p = (1+sqrt(5))/2, ip = 1/p, fscle = (3+sqrt(3)*(p-1))/(p+1), fbaserad = fscle*2*sqrt(3)/3
scale = 0.4, fii = 13, fjj = 21, fks = 20, fk = fks, rlevel = 181
initSpheres()
endfunc
; Initializes base and generator spheres
func InitSpheres()
complex Fc[54]
float Fz[54]
float Fr[54]
Fc[0] = (1,0)*fscle, Fc[1] = (1,0)*fscle, Fc[2] = (-1,0)*fscle, Fc[3] = (-1,0)*fscle
Fc[4] = flip(p)*fscle, Fc[5] = flip(p)*fscle, Fc[6] = -flip(p)*fscle, Fc[7] = -flip(p)*fscle
Fc[8] = (p+flip(1))*fscle, Fc[9] = (p-flip(1))*fscle, Fc[10] = (-p+flip(1))*fscle
Fc[11] = (-p-flip(1))*fscle, Fc[12] = (0,0), Fc[13] = (1,1), Fc[14] = (-1,1)
Fc[15] = (1,-1), Fc[16] = (1,1), Fc[17] = (-1,-1), Fc[18] = (-1,1), Fc[19] = (1,-1)
Fc[20] = (-1,-1), Fc[21] = flip(ip), Fc[22] = -flip(ip), Fc[23] = flip(ip)
Fc[24] = -flip(ip), Fc[25] = ip+flip(p), Fc[26] = -ip+flip(p), Fc[27] = ip-flip(p)
Fc[28] = -ip-flip(p), Fc[29] = p, Fc[30] = -p, Fc[31] = p, Fc[32] = -p, Fc[33] = (0,0)
Fc[34] = (1,1), Fc[35] = (-1,1), Fc[36] = (1,-1), Fc[37] = (1,1), Fc[38] = (-1,-1)
Fc[39] = (-1,1), Fc[40] = (1,-1), Fc[41] = (-1,-1), Fc[42] = flip(ip), Fc[43] = -flip(ip)
Fc[44] = flip(ip), Fc[45] = -flip(ip), Fc[46] = ip+flip(p), Fc[47] = -ip+flip(p)
Fc[48] = ip-flip(p), Fc[49] = -ip-flip(p), Fc[50] = p, Fc[51] = -p, Fc[52] = p, Fc[53] = -p
Fz[0] = p*fscle, Fz[1] = -p*fscle, Fz[2] = p*fscle, Fz[3] = -p*fscle, Fz[4] = fscle
Fz[5] = -fscle, Fz[6] = fscle, Fz[7] = -fscle, Fz[8] = 0, Fz[9] = 0, Fz[10] = 0
Fz[11] = 0, Fz[12] = 0, Fz[13] = 1, Fz[14] = 1, Fz[15] = 1, Fz[16] = -1, Fz[17] = 1
Fz[18] = -1, Fz[19] = -1, Fz[20] = -1, Fz[21] = p, Fz[22] = p, Fz[23] = -p,, Fz[24] = -p
Fz[25] = 0, Fz[26] = 0, Fz[27] = 0, Fz[28] = 0, Fz[29] = ip, Fz[30] = ip, Fz[31] = -ip
Fz[32] = -ip, Fz[33] = 0, Fz[34] = 1, Fz[35] = 1, Fz[36] = 1, Fz[37] = -1, Fz[38] = 1
Fz[39] = -1, Fz[40] = -1, Fz[41] = -1, Fz[42] = p, Fz[43] = p, Fz[44] = -p
Fz[45] = -p, Fz[46] = 0, Fz[47] = 0, Fz[48] = 0, Fz[49] = 0, Fz[50] = ip, Fz[51] = ip
Fz[52] = -ip, Fz[53] = -ip
Fr[0] = fbaserad, Fr[1] = fbaserad, Fr[2] = fbaserad, Fr[3] = fbaserad, Fr[4] = fbaserad
Fr[5] = fbaserad, Fr[6] = fbaserad, Fr[7] = fbaserad, Fr[8] = fbaserad, Fr[9] = fbaserad
Fr[10] = fbaserad, Fr[11] = fbaserad, Fr[12] = p, Fr[13] = p-1, Fr[14] = p-1
Fr[15] = p-1, Fr[16] = p-1, Fr[17] = p-1, Fr[18] = p-1, Fr[19] = p-1, Fr[20] = p-1
Fr[21] = p-1, Fr[22] = p-1, Fr[23] = p-1, Fr[24] = p-1, Fr[25] = p-1, Fr[26] = p-1
Fr[27] = p-1, Fr[28] = p-1, Fr[29] = p-1, Fr[30] = p-1, Fr[31] = p-1, Fr[32] = p-1
Fr[33] = sqrt(3)+p-1, Fr[34] = p-1, Fr[35] = p-1, Fr[36] = p-1, Fr[37] = p-1
Fr[38] = p-1, Fr[39] = p-1, Fr[40] = p-1, Fr[41] = p-1, Fr[42] = p-1, Fr[43] = p-1
Fr[44] = p-1, Fr[45] = p-1, Fr[46] = p-1, Fr[47] = p-1, Fr[48] = p-1, Fr[49] = p-1
Fr[50] = p-1, Fr[51] = p-1, Fr[52] = p-1, Fr[53] = p-1
int i = 0
; scale and translate the spheres to screen dimensions
;
repeat
if reflect
Fc[i] = -conj(Fc[i])
else
Fc[i] = Fc[i]
endif
; Z axis rotation
Fc[i] = Fc[i]*zrot
; Y axis rotation
temp = real(Fc[i]) + flip(Fz[i])
temp = temp*yrot
Fc[i] = real(temp) + flip(imag(Fc[i]))
Fz[i] = imag(temp)
; X axis rotation
temp = imag(Fc[i]) + flip(Fz[i])
temp = temp*xrot
Fc[i] = real(Fc[i]) + flip(real(temp))
Fz[i] = imag(temp)
; scaling
Fc[i] = Fc[i]*#magn*scale
Fz[i] = Fz[i]*#magn*scale
if i > 12
Fr[i] = Fr[i]*#magn*scale*@bradadj
else
Fr[i] = Fr[i]*#magn*scale*@radadj
endif
i = i+1
until i == 54
; declare the generator spheres
;
; dodecahedron
fg[0] = new Sphere(Fc[0],Fz[0],Fr[0],0,0), fg[1] = new Sphere(Fc[1],Fz[1],Fr[1],0,1)
fg[2] = new Sphere(Fc[2],Fz[2],Fr[2],0,2), fg[3] = new Sphere(Fc[3],Fz[3],Fr[3],0,3)
fg[4] = new Sphere(Fc[4],Fz[4],Fr[4],0,4), fg[5] = new Sphere(Fc[5],Fz[5],Fr[5],0,5)
fg[6] = new Sphere(Fc[6],Fz[6],Fr[6],0,6), fg[7] = new Sphere(Fc[7],Fz[7],Fr[7],0,7)
fg[8] = new Sphere(Fc[8],Fz[8],Fr[8],0,8), fg[9] = new Sphere(Fc[9],Fz[9],Fr[9],0,9)
fg[10] = new Sphere(Fc[10],Fz[10],Fr[10],0,10), fg[11] = new Sphere(Fc[11],Fz[11],Fr[11],0,11)
fg[12] = new Sphere(Fc[12],Fz[12],Fr[12],0,12)
;
; declare the base Spheres
;
; dodecahedron
fb[0] = new Sphere(Fc[13],Fz[13],Fr[13],0,0), fb[1] = new Sphere(Fc[14],Fz[14],Fr[14],0,1)
fb[2] = new Sphere(Fc[15],Fz[15],Fr[15],0,2), fb[3] = new Sphere(Fc[16],Fz[16],Fr[16],0,3)
fb[4] = new Sphere(Fc[17],Fz[17],Fr[17],0,4), fb[5] = new Sphere(Fc[18],Fz[18],Fr[18],0,5)
fb[6] = new Sphere(Fc[19],Fz[19],Fr[19],0,6), fb[7] = new Sphere(Fc[20],Fz[20],Fr[20],0,7)
fb[8] = new Sphere(Fc[21],Fz[21],Fr[21],0,8), fb[9] = new Sphere(Fc[22],Fz[22],Fr[22],0,9)
fb[10] = new Sphere(Fc[23],Fz[23],Fr[23],0,10), fb[11] = new Sphere(Fc[24],Fz[24],Fr[24],0,11)
fb[12] = new Sphere(Fc[25],Fz[25],Fr[25],0,12), fb[13] = new Sphere(Fc[26],Fz[26],Fr[26],0,13)
fb[14] = new Sphere(Fc[27],Fz[27],Fr[27],0,14), fb[15] = new Sphere(Fc[28],Fz[28],Fr[28],0,15)
fb[16] = new Sphere(Fc[29],Fz[29],Fr[29],0,16), fb[17] = new Sphere(Fc[30],Fz[30],Fr[30],0,17)
fb[18] = new Sphere(Fc[31],Fz[31],Fr[31],0,18), fb[19] = new Sphere(Fc[32],Fz[32],Fr[32],0,19)
fb[20] = new Sphere(Fc[33],Fz[33],Fr[33],0,20)
bradius = fb[0].frad
s.sph[0] = new Sphere(Fc[34],Fz[34],Fr[34],0,0), s.sph[1] = new Sphere(Fc[35],Fz[35],Fr[35],0,1)
s.sph[2] = new Sphere(Fc[36],Fz[36],Fr[36],0,2), s.sph[3] = new Sphere(Fc[37],Fz[37],Fr[37],0,3)
s.sph[4] = new Sphere(Fc[38],Fz[38],Fr[38],0,4), s.sph[5] = new Sphere(Fc[39],Fz[39],Fr[39],0,5)
s.sph[6] = new Sphere(Fc[40],Fz[40],Fr[40],0,6), s.sph[7] = new Sphere(Fc[41],Fz[41],Fr[41],0,7)
s.sph[8] = new Sphere(Fc[42],Fz[42],Fr[42],0,8), s.sph[9] = new Sphere(Fc[43],Fz[43],Fr[43],0,9)
s.sph[10] = new Sphere(Fc[44],Fz[44],Fr[44],0,10), s.sph[11] = new Sphere(Fc[45],Fz[45],Fr[45],0,11)
s.sph[12] = new Sphere(Fc[46],Fz[46],Fr[46],0,12), s.sph[13] = new Sphere(Fc[47],Fz[47],Fr[47],0,13)
s.sph[14] = new Sphere(Fc[48],Fz[48],Fr[48],0,14), s.sph[15] = new Sphere(Fc[49],Fz[49],Fr[49],0,15)
s.sph[16] = new Sphere(Fc[50],Fz[50],Fr[50],0,16), s.sph[17] = new Sphere(Fc[51],Fz[51],Fr[51],0,17)
s.sph[18] = new Sphere(Fc[52],Fz[52],Fr[52],0,18), s.sph[19] = new Sphere(Fc[53],Fz[53],Fr[53],0,19)
endfunc
float p
float ip
default:
title = "Dodecahedron"
int param v_dodecahedron
caption = "Version (Dodecahedron)"
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_dodecahedron < 100
endparam
}