Coils - generate coils, springs and the like for POV-Ray scenes

SYNOPSIS

coils [ -as? ] [ -r rotations ] [ -t tightness ] [ -w width ] [ -W width ] 
      [ -f filename ] [ -N object ] [ -o output_format ]

DESCRIPTION

The coils program produces an output file suitable for use with rendering programs that model coils or springs. Currently only POV-Ray include files are supported for output formats.

The final object is centered about the origin and the X axis. This means the left and right ends of the coil are equadistance along the X axis from the origin. The coordinates of both ends of the coil are provided in the comment section of the output file. No textures are provided.

OPTIONS

-r rotations Specifies the number of 360 degree rotations in the coil.
-t tightness Specifies the offset of end of rotation from start of rotation along rotation axis.
-w radius Specifies the radius of the coil strand (minor radius of torus).
-W radius Specifies the radius of a single rotation (major radius of torus).
-s Use the sturm option for all torii.
-a Append to output file, if it already exists.
-f filename Filename to write output to (default: coils.inc).
-N object Name of the object (default: coil).
-o type Output format type. This can be one of the following:
  1. POV-Ray
Currently this option does not need to be specified since it defaults to POV-Ray.

EXAMPLE USAGE

Suppose you want to create a coiled strand around a barrel, where each rotation of the coil touches its adjoining neighbor. Suprisingly, thats exactly why I wrote this little ditty. How would you do this? You need to know the following things:

  1. The number of rotations the strand will make. 10 rotations should be enough for this example.
  2. The radius of the strand. Lets say our barrel is 8 units long and will have 10 rotations in its coil, we'll need 8/(10/2)=1.6 units. Remember, this is the minor radius value for the torii that will make up the coil.
  3. The radius of a complete rotation of the strand. We'll make our barrel 4 units in diameter, so the radius of a complete rotation of the coil around the barrel would be 2+1.6=3.6.
  4. The distance between the apex of one rotation of the strand to the apex of the next rotation of the strand. This is the tightness. This is simply 2 times the radius of the strand, since each rotation touches its neighbor. For springs this value would be greater than 2 times the strand radius, so there is empty space between each rotation.

We also want two of these coils, with unique names but in the same include file. The include file should be called "mycoils.inc". We'll need to run the coils command twice. The first invokation would be as follows:

coils -r 10 -w 1.6 -W 3.6  -t  3.2  -f  mycoils.inc  -N coil1

The next invokation needs to tell coils program to append to an existing file. We do this with the -a option:

coils -a -r 10 -w 1.6 -W 3.6 -t 3.2 -f  mycoils.inc  -N coil2

Viola! You now have two coils named coil1 and coil2 that can be used within your POV-Ray scene file.

HOW DOES IT WORK

The coils program creates two half torii, each with one end anchored on the origin. It then rotates each of these an appropriate amount so that the unanchored end is offset half the tightness distance from the verticle axis. The two half torii are then connected to create a single full rotation. This object is then used to create a coil of how ever many strands the user requires.

SEE ALSO

gears(1), genf(1)

BUGS

It was quick and dirty and if you do stupid things it breaks. So, don't do stupid things.

The command line options use atof() to convert the input to a double. This only provides 6 digit precision unfortunately. I'm too lazy to convert this to a long double function so if you need greater precision you'll need to replace the atof() calls to your own version.

Torii are notorious for slowing the processing of an image. Although a bounding box around the coil helps speed processing, you should be aware that the coil itself will be quite slow to render, especially if you include a large number of rotations.

AUTHOR

Copyright 1996 by Michael J. Hammel <mjhammel@csn.net>

(clear space) Michael J. Hammel <mjhammel@csn.net>
(clear space) Created: June 7, 1996
Updated: June 7, 1996