////////////////////////////////////////////////////////// // my version of that tried and true object, the coil. // this one is done using toroidal half-sections. // It places the coil between points P1 and P2 with // coil spacing dY. The coil has major radius R1 // and minor radius R2. It will show distortion if // dY is comparable to R1, or larger. // // Dan Connelly : 26Sept1998 #ifdef (TorusCoil_Inc) #else #declare TorusCoil_Inc = version; #version 3.1; #include "VectorTransform.inc" // VectorAlign macro needed #macro TorusCoil(P1, P2, dY, R1, R2) #local T = degrees(asin(dY / (4 * R1))); #local Ymax = vlength(P2 - P1); #local Segment = union { #declare Y = dY / 4; #while (Y < Ymax - dY / 2) torus { R1, R2 clipped_by { plane {-z, 0} } rotate T * z translate Y * y } #declare Y = Y + dY; #end } union { object { Segment } object { Segment rotate 180 * y translate dY/2 * y } VectorAlign(y, (P2 - P1)) translate P1 } #end #version TorusCoil_Inc; #end