/* -*-flix-*- */
// Steiner's Roman surface, using "surface" plots
// May 19, 2006
#include "epix.h"

using namespace ePiX;

double MAX(2.5), rad(0.8*MAX);

P F(double u, double v)
{
  double x(rad*Cos(u)*Cos(v)), y(rad*Cos(u)*Sin(v)), z(rad*Sin(u));
  return P(y*z, x*z, x*y);
}

P color(double x, double y)
{
#ifdef COLORSHADE
  return P(0.5*Sin(x), -0.5*Sin(x), Cos(y));
#else
  return P(1,1,1); // white
#endif
}

int main(int argc, char* argv[])
{
  if (argc == 3)
    {
      char* arg;
      double temp1, temp2;
      temp1=strtod(argv[1], &arg);
      temp2=strtod(argv[2], &arg);

      tix()=temp1/temp2;
    }
  picture(P(-MAX,-MAX),P(MAX,MAX), "4x4in");

  begin();

  backing(RGB(0.7, 0.9, 1));

  fill();
  revolutions();
  camera.at(cyl(10, 0.5*tix(), 2)); // exploit 2-fold symmetry

  surface(F, domain(P(-0.25, 0), P(0.25, 0.5), mesh(32,32), mesh(64,64)), color);

  pst_format();
  end();
}
