#include <stdio.h>
#include <math.h>

#define PI 3.14159

int
main( argc, argv, envp )
	int argc;
	char * argv[];
	char * envp[];
{
	int stepsPerRev = 30;       /* How many steps per revolution to build */
	int revs = 2;                  /* How many helix revolutions to build */
	float radius = 2.0;                     /* Outter radius of the helix */

	int steps = revs * stepsPerRev;               /* Total steps to build */
	int step;                                      /* Current step number */
	float delta = 2.0*PI/(float)stepsPerRev;    /* Step size (in radians) */
	float theta;                     /* Current step's angle (in radians) */
	float x, y, z;                     /* Current step's spine coordinate */

	/* Generate an Extrusion representing the function */

	/* Build Extrusion cross section (a rectangle) */
	/* Rectangle 1.0 x 0.2 */
	printf( "# crossSection\n" );
	printf( "\t-0.5 -0.1,\n" );
	printf( "\t-0.5 +0.1,\n" );
	printf( "\t+0.5 +0.1,\n" );
	printf( "\t+0.5 -0.1,\n" );
	printf( "\t-0.5 -0.1,\n" );

	/* Build the Extrusion spine (a helix) */
	/* Helix */
	printf( "# spine positions\n" );
	for ( step=0; step<steps; step++ )
	{
		theta = (float) step * delta;
		x = sin( theta ) * radius;
		y = (float) step / 15.0;
		z = cos( theta ) * radius;
		printf( "\t%f %f %f,\n", x, y, z );
	}

	/* Output times */
	/* Helix */
	printf( "# key times\n" );
	for ( step=0; step<steps; step++ )
	{
		printf( "\t%f,\n", ((float)step)/((float)steps) );
	}

	/* Build the Extrusion spine (a helix) */
	/* Helix */
	printf( "# key positions\n" );
	for ( step=0; step<steps; step++ )
	{
		theta = (float) step * delta;
		x = sin( theta ) * radius;
		y = (float) step / 15.0;
		z = cos( theta ) * radius;
		printf( "\t%f %f %f,\n", x, y, z );
	}

}

