#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

double xo, yo, zo;

void init(void)
{
 cout << "#include \"colors.inc\"\n";
 cout << "light_source { <0,10,-10> color White }\n";
 cout << "light_source { <10,0,-10> color White }\n";
 cout << "camera { location <0,0,-40> direction z look_at <0,0,0> }\n";
}

void moveto(double x, double y, double z)
{
  cout << "sphere { <" << x << "," << y << "," << z << ">, 0.5 " 
       << "pigment { color Green } }\n";
  xo= x; yo=y; zo=z;
}

void lineto(double x, double y, double z) 
{ 
   cout << "cylinder { <" << xo << "," << yo << "," << zo << ">, " 
        <<           " <" << x  << "," << y  << "," << z  << ">, 0.5 " 
        << "pigment { color Green } }\n";
   moveto(x,y,z);
}

double fx(double t)
{
   return 6*cos( M_PI/2+t ) + 2*cos(M_PI/2-1.5*t);
}

double fz(double t)
{
   return 6*sin(2.5*t);
}

double fy(double t)
{
   return 6*sin( M_PI/2+t ) + 2*sin(M_PI/2-1.5*t);
}

int main(void)
{
  init(); 
  double t=0;
  double a= 0;
  double b= 4*M_PI;
  int    n= 100;

  moveto(fx(a), fy(a), fz(a)); 
  for (int k=1; k<=n; k++)
    {
     t= a+ k*(b-a)/n;
     lineto(fx(t), fy(t), fz(t));
    }
}


