//Description: // A modification of Tsutomu Higo's recursive zigzag code // 2d here, a simple zigzag generator produces very complex result //Author: Ben Scheele //Date: 3-19-2003 camera { location <.5,0,-10> look_at x/2 angle 9 } light_source{ <4,10,-20> rgb .5 } light_source{ <-4,-10,-20> rgb .5 } plane{ z, .6 pigment{ rgb .5 } finish{ reflection .6 } hollow } background{ rgb .5 } #declare Nx = 4; #declare Data = array [Nx][2] {{60,0},{-60,0},{-60,0},{60,0}} // transformations of objects * #declare rad = .3; #declare levels = 8; // number of recursion levels, set to 1 to see the generator // increase step by step to see the process #declare Unit = union{ cylinder{ 0, y, rad } sphere{ y rad } } #declare J = 0; #while (J < levels) #declare Unit = #declare Sc = 1; #declare Xp = 0; #declare Yp = 0; #declare Zp = 0; union{ #declare I = 0; #while (I < Nx) object{ Unit rotate //rotates depending on the transformations you define * translate } #declare Xp = Sc*( Xp + sin( Data[I][0]*pi/180 )*sin( Data[I][1]*pi/180 )); #declare Yp = Sc*( Yp + cos( Data[I][0]*pi/180 )); #declare Zp = Sc*( Zp + sin( Data[I][0]*pi/180 )*cos( Data[I][1]*pi/180 )); #declare I = I + 1; #end #declare Sc = 1/sqrt( Xp*Xp + Yp*Yp + Zp*Zp ); scale Sc } #declare J = J + 1; #end #declare unit2= object{ Unit pigment{ rgb <.85,.65,.05> } finish{ ambient .1 diffuse .5 reflection{ .3 .5 metallic .5 } metallic .3 phong .6 specular .6 roughness .01 brilliance .8 } rotate <90,90> } object{ unit2 }