// t01.c
// v0.1 KHL 2009-04-21
// gcc -o t01 t01.c -lm -lgd ; ./t01
// static drawing, though slow to compute
// earth and toroid around orbit

#define TITLE    "M288, 1 center orbit"
#define GIFOUT   "t01.gif"
#define DELTANG 0.2
#define ORBWIDTH  9
#define ANG0      0
#define ANG1     90
#define ANG2    142
#define NELIP    32

#include "tor00.hc"

int main () {
   double  t_ang ;
   int     e_cnt ;
   int     orb ;
   int     norb ;
 
   gdPoint ellipse[NELIP+2];

   displaystart();
   torstart();

   gdImageGifAnimBegin( im1, gifout, 1, -1 ) ; // no repeat
   // gdImageGifAnimBegin( im1, gifout, 1,  4 ) ; // repeat 4 times
   // gdImageGifAnimBegin( im1, gifout, 1,  0 ) ; // continuous repeat

   framestart(    90, TITLE );

   for( t_ang=-ANG1 ; t_ang < ANG1 ; t_ang += DELTANG ) {
      double  angle_rad=DEG2RAD( t_ang );
      double  tox = -major*sin( angle_rad );
      double  toz = -major*cos( angle_rad );
      gdPoint pto = sr0( tox, 0.0, toz );
      gdImageFilledEllipse( im, pto.x, pto.y, ORBWIDTH, ORBWIDTH, tc[0]);
   }
   drawearth();

   for( t_ang=ANG1 ; t_ang < 360-ANG1 ; t_ang += DELTANG ) {
      double  angle_rad=DEG2RAD( t_ang );
      double  tox = -major*sin( angle_rad );
      double  toz = -major*cos( angle_rad );
      gdPoint pto = sr0( tox, 0.0, toz );
      gdImageFilledEllipse( im, pto.x, pto.y, ORBWIDTH, ORBWIDTH, tc[0]);
   }

   frameend();
   displayend();
   return 0;
}
