// Persistence of Vision Ray Tracer 3.5(beta) Include File // File: Peano3D.inc // Ver.: 0.6 // Desc: Macros for 3D Peano(Hilbert) Space-Filling curve // Date: 01/27/2002 // Auth: Gleb Koloskov // ///////// // Hist: // 01/27/2002 Extra unions generated warnings removed // 01/26/2002 v0.5 posted to p.b.s-f // pAtom macros #macro pAtom(x0,y0,z0,x1,y1,z1,r) cylinder{,r} sphere{,r} sphere{,r} #end // L = Recursion Level // D = Box size // r = radius of cylinder(or any other atom) to draw #macro Peano3dR(L, D, r) // Recursive Part #local D2=D/2; #local D4=D/4; #local dMin2=D2/(2^L); #if(L>1) // 1 union{ Peano3dR(L-1,D/2,r) rotate 90*z rotate 90*y translate <-D4,-D4,-D4> } // 2 union{ Peano3dR(L-1,D/2,r) rotate -90*x rotate -90*y translate } // 3 union{ Peano3dR(L-1,D/2,r) rotate -90*x rotate -90*y translate } // 4 union{ Peano3dR(L-1,D/2,r) rotate -90*z rotate 180*y translate <-D4,D4,-D4> } // 5 union{ Peano3dR(L-1,D/2,r) rotate -90*z rotate 180*y translate <-D4,D4,D4> } // 6 union{ Peano3dR(L-1,D/2,r) rotate -90*x translate } // 7 union{ Peano3dR(L-1,D/2,r) rotate -90*x translate } // 8 union{ Peano3dR(L-1,D/2,r) rotate 90*z rotate -90*y translate <-D4,-D4,D4> } #end Peano3d0(D2,dMin2, r) #end #macro Peano3d0(D2,dMin2, r) // Low Level Part pAtom(-dMin2,-D2+dMin2,-D2+dMin2,dMin2,-D2+dMin2,-D2+dMin2,r) pAtom(dMin2,-dMin2,-D2+dMin2,dMin2,dMin2,-D2+dMin2,r) pAtom(dMin2,D2-dMin2,-D2+dMin2,-dMin2,D2-dMin2,-D2+dMin2,r) pAtom(-dMin2,D2-dMin2,-dMin2,-dMin2,D2-dMin2,dMin2,r) pAtom(-dMin2, D2-dMin2,D2-dMin2,dMin2,D2-dMin2,D2-dMin2,r) pAtom(dMin2,dMin2,D2-dMin2,dMin2,-dMin2,D2-dMin2,r) pAtom(dMin2,-D2+dMin2,D2-dMin2,-dMin2,-D2+dMin2,D2-dMin2,r) #end // L = Recursion Level // D = Box size // r = radius of cylinder(or any other atom) to draw #macro Peano3d(L, D, r) union{ #if(int(L)>1) Peano3dR(int(L), D, r) #else #if(int(L)=1) Peano3d0(D/2,D/4, r) #else #warning concat("Recursion Level = ",str(L,0,-1)," is outside expected range\n") #end #end } #end /* Example: #include "colors.inc" #include "Peano3D.inc" camera { location <-1.2,1.4,-0.8>*0.7 look_at <0.0,0.0,0.0> } background { color rgb <.2, .3, .4> } light_source{ <-4.470,4.533,4.883> rgb<1.000,1.000,1.000> spotlight point_at 0 radius 60 falloff 120 tightness 10.0 } light_source{ <4.470,4.533,-4.883> rgb<1.000,1.000,1.000> spotlight point_at 0 radius 60 falloff 120 tightness 10.0 } #declare H2x2x2=Peano3d(1,1,0.04); #declare H4x4x4=Peano3d(2,1,0.02); #declare H8x8x8=Peano3d(3,1,0.01); #declare H16x16x16=Peano3d(4,1,0.005); #declare T_001=texture{ pigment { agate color_map { [0.0 color Green ] [1.0 color Blue ] } } finish { ambient 0.1 diffuse 0.6 reflection { 1.0 metallic 0.75 } } } #object{H2x2x2 scale 0.25 translate <-0.625,0,0> texture{T_001}} #object{H4x4x4 scale 0.25 translate <-0.325,0,0.0> texture{T_001}} #object{H8x8x8 scale 0.25 translate <0.0425,0,0.00> texture{T_001}} #object{H16x16x16 scale 0.25 translate <0.625,0.0> texture{T_001}} */