#include "epix2.h"
using namespace ePiX2;

int N1(36), N2(32); // must be multiples of 4

int main() {

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

  Pen red(bbold(Red()));
  Pen green(bold(Green(0.6)));
  Pen yellow(plain(Yellow()));

#ifdef ORTHANTS
  Sphere S1(Origin, 2, N1, N2);
  // S1.rotate(-M_PI_4,E_1()).limn(yellow);
  S1.limn(yellow);
  S1.chop(Knife(E_1(), red))
    .chop(Knife(E_2(), red))
    .chop(Knife(E_3(), red));

  Sphere S2(Origin, 2, N1, N2);
  // S2.rotate(-M_PI_4,E_1()).limn(yellow);
  S2.limn(yellow);
  S2.chop(Knife( E_1(), red))
    .chop(Knife(-E_2(), red))
    .chop(Knife(-E_3(), red));

  Sphere S3(Origin, 2, N1, N2);
  // S3.rotate(-M_PI_4,E_1()).limn(yellow);
  S3.limn(yellow);
  S3.chop(Knife(-E_1(), red))
    .chop(Knife( E_2(), red))
    .chop(Knife(-E_3(), red));

  Sphere S4(Origin, 2, N1, N2);
  S4.limn(yellow);
  // S4.rotate(-M_PI_4,E_1()).limn(yellow);
  S4.chop(Knife(-E_1(), red))
    .chop(Knife(-E_2(), red))
    .chop(Knife( E_3(), red));

  world << S1 << S2 << S3 << S4;
#endif

#ifdef SKEL
  Compound S5;
  for (int i=0; i<0.25*N1; ++i) // longitudes
    {
      Vector perp(Origin, Cos(4*i*M_PI/N1), Sin(4*i*M_PI/N1), 0);
      S5 << Circle(Origin, 2, perp);
    }

  for (int j=1; j<0.25*N2; ++j)
    {
      Point ctr(0,0,2*Cos(4*j*M_PI/N2));
      S5 << Circle(ctr, 2*Sin(4*j*M_PI/N2), E_3(ctr));
    }

  text_style().text(Red()).back(White()).align(bl);
  // S5.rotate(-M_PI_4,E_1()).stroke(yellow);
  world << S5.stroke(yellow);
  //	<< Label(Point(0,0,2), "$N$", MK_BOX);
#endif

  camera.at(Point(8,10,12)).roll(M_PI/6);

  Ink gold(RGB(1,0.9,0.6), 0.5, true);

  world.paint(gold);
  world.light(Point(1,-20,60), Green())
    .light(Point(40,-20,-20), Blue())
    .light(Point(-40,-20,-20), Red())
    .light(Point(1,-20,-20));

  world.photo(picture, camera);
  picture.print_to("orthants.eepic", PSTricks());
}
