#version 3.6; #declare RANGE = 5; #declare VP = RANGE*vnormalize(); #declare VU = <0,0,1>; camera { perspective location VP up y right x*image_width/image_height angle 60 sky VU look_at <0,0,0> } background { color rgb <0,0,0> } global_settings { assumed_gamma 1.8 } // Light sources light_source { <0,1,10> color rgb <1,1,1> } light_source { VP color rgb 0.5*<1,1,1> } #declare curvetexture = texture { pigment { colour rgb <1.0,0.5,0.5> } finish { ambient 0.1 diffuse 0.8 specular 0.4 } } #declare ringthickness = 0.02; #declare ringthicknessfactor = 0.75; // 1 for constant thickness #declare ringscalefactor = 0.35; #declare gapangle = 60; #declare level_max = 2; #declare p1 = ; #declare p2 = <-sin(radians(gapangle/2)), 1+cos(radians(gapangle/2)), 0>; // Create a torus with or without a gap #macro torus_macro2(ang,r_ring) union { #declare theta = 0; #while (theta <= 360-ang) sphere { , r_ring rotate <0,0,-ang/2> translate <0,1,0> } #if (theta < 360-ang) cylinder { , , r_ring rotate <0,0,-ang/2> translate <0,1,0> } #end #declare theta = theta + 1; #end texture { curvetexture } } #end #macro recursive_torus(L,r_ring) #if (L = level_max) // Create a complete torus for the deepest iteration union { torus_macro2(0,r_ring) } #else union { union { torus_macro2(gapangle,r_ring) } object { recursive_torus(L+1,r_ring*ringthicknessfactor/ringscalefactor) scale ringscalefactor rotate <0,0,90> translate p1 } object { recursive_torus(L+1,r_ring*ringthicknessfactor/ringscalefactor) scale ringscalefactor rotate <0,90,0> rotate <0,0,-90> translate p2 } } #end #end object { recursive_torus(0,ringthickness) rotate <90,0,0> translate <0,0,-1-ringscalefactor/2> }