// HORN.POV // creates a horn-like shape from spheres and cones // by Guy Rauscher Feb 9, 1997 #include "colors.inc" #include "textures.inc" #default { pigment { color White } finish { Shiny } } camera { location <0,10,-30> look_at <0,0,0> } light_source { <5,20,-20> color White*1.5 } #declare horn = union { #declare A1 = 0 // initial angle #declare A2 = 80 // final angle #declare Rx = 7 // major radius in the X dimention #declare Ry = 9 // major radius in the Y dimention #declare Tk0 = 1.5 // Initial radius of horn #declare Tkf = 0.2 // Final radius of horn #declare T = .2 // Amount in degrees to add each time (smaller=smoother) #declare Tk = Tk0 #declare lastX = Rx * cos(radians(A1)) #declare lastY = Rx * sin(radians(A1)) * Ry / Rx #declare D = A1 + T #while (D<=A2) // equations of z-axis rotation (without Y, it's zero) #declare X1 = Rx * cos(radians(D)) #declare Y1 = Rx * sin(radians(D)) // adjust for Y radius #declare Y1 = Y1 * Ry / Rx // create objects sphere { , Tk } cone { , Tk, , Tk0 + (Tkf-Tk0) * (D-A1)/(A2-A1) } // update variables #declare D = D + T #declare Tk = Tk0 + (Tkf-Tk0) * (D-A1)/(A2-A1) // make horn radius smaller #declare lastX = X1 #declare lastY = Y1 #end // end with a sphere #if(Tkf > 0) sphere { , Tkf } #end } // This is how it comes out of the loop: // object { horn } // This creates two horns minus a head to link them object { horn translate -x*Rx rotate -z*90 translate x*Rx*0.3 } object { horn translate -x*Rx rotate -z*90 translate x*Rx*0.3 scale <-1,1,1> }