#include "epix2.h"
using namespace ePiX2;

Point torus(double u, double v)
{
  double r(0.5), R(1.+r*Cos(u));
  return Point(R*Cos(v), R*Sin(v), r*Sin(u));
}

Point f(double t)
{
  return torus(t/60.0, t/140.0);
  //return Point(Sin(0.02*M_PI*t), Sin(0.03*M_PI*t), Cos(0.01*M_PI*t));
}

Point g(double t)
{
  return torus(0.25+t/60.0, t/140.0);
  //return Point(Sin(0.02*M_PI*t), Sin(0.03*M_PI*t), Cos(0.01*M_PI*t));
}

int main() {

  World world;

  Camera camera;
  Picture picture(Pair(-2,-2), Pair(2,2), "6x6in");

  picture.backing(Black(0.7));

  std::string fore("1pt"), aft("2.5pt");
  // Ink lt_green(Green(1.2)), dk_green(Green(0.6));
  Duo_Pen green(Green(1.2), fore, Green(0.6), aft);
  Duo_Pen blue(Blue(1.5), fore, Blue(0.8), aft);
  Duo_Pen neon(Red(1.5), fore, Red(0.6), aft);

  world << Circle().stroke(neon);
  rotations();

  for (int i=0; i<420; ++i)
    world << Segment(f(i), f(i+1)).stroke(green)
	  << Segment(g(i), g(i+1)).stroke(blue);

  camera.at(Point(2, 6, 3));

  world.fog(Black(), 0.75,6);

  world.photo(picture, camera);
  picture.crop();

  print(picture, "knots2.eepic", PSTricks());
}
