Attachment 't24.c'

Download

   1 // t24.c
   2 // v0.1 KHL 2009-04-21
   3 // gcc -o t24 t24.c -lm -lgd ; ./t24
   4 // static drawing, though slow to compute
   5 // earth and toroid around orbit
   6 
   7 #define TITLE    "M288, 1 center and 24 toroid orbits"
   8 #define GIFOUT   "t24.gif"
   9 #define NORB     24
  10 #define DELTANG 0.2
  11 #define ORBWIDTH  9
  12 #define ANG0      0
  13 #define ANG1     90
  14 #define ANG2    142
  15 #define NELIP    32
  16 
  17 #include "tor00.hc"
  18 
  19 int main () {
  20    double  t_ang ;
  21    int     e_cnt ;
  22    int     orb ;
  23    int     norb ;
  24  
  25    gdPoint ellipse[NELIP+2];
  26 
  27    displaystart();
  28    torstart();
  29 
  30    gdImageGifAnimBegin( im1, gifout, 1, -1 ) ; // no repeat
  31    // gdImageGifAnimBegin( im1, gifout, 1,  4 ) ; // repeat 4 times
  32    // gdImageGifAnimBegin( im1, gifout, 1,  0 ) ; // continuous repeat
  33 
  34    framestart(    90, TITLE );
  35 
  36    // draw back portion of the orbit toroid
  37   
  38    double acolor =  0.0 ;
  39    if(  NORB > 0 ) { norb = 1 + NORB ; }
  40    else            { norb = 1 - NORB ; }
  41 
  42    for( t_ang=ANG0 ; t_ang < ANG2 ; t_ang += DELTANG ) {
  43 
  44       double ecolor ;
  45       if( acolor < 0.5 ) { ecolor = gray ; }
  46       else {
  47          ecolor = lgray ;
  48          if( acolor > 14.5 ) { acolor -= 15.0 ; }
  49       }
  50       acolor += DELTANG ;
  51 
  52       double angle_rad=DEG2RAD( t_ang );
  53 
  54       // ellipse disk - since it is at an angle, we will have to draw it
  55       // as a filled polygon
  56     
  57       // ellipse disk on left
  58       for( e_cnt=0 ; e_cnt < NELIP ; e_cnt++ ) {
  59          double toa = angle_rad + (2.0*PI*e_cnt)/NELIP  ;
  60          double tos = td[ norb-1 ] * step ;                 // step size
  61          double tor = tos * cos( toa );
  62          double toy = tos * sin( toa );
  63          double tox = -(major+tor)*sin( angle_rad );
  64 	 double toz = -(major+tor)*cos( angle_rad );
  65 	 ellipse[e_cnt] = sr0( tox, toy, toz );
  66       }
  67       if( ( NORB < 0 ) && ( t_ang > ( ANG2-DELTANG ) ) ) {
  68          gdImageFilledPolygon( im, ellipse, NELIP, black );
  69       }
  70       gdImagePolygon( im, ellipse, NELIP, ecolor );
  71 
  72 
  73       // ellipse disk on right
  74       for( e_cnt=0 ; e_cnt < NELIP ; e_cnt++ ) {
  75          double toa = -angle_rad + (2.0*PI*e_cnt)/NELIP  ;
  76          double tos = td[ norb-1 ] * step ;                 // step size
  77          double tor = tos * cos( toa );
  78          double toy = tos * sin( toa );
  79          double tox = -(major+tor)*sin( -angle_rad );
  80          double toz = -(major+tor)*cos( -angle_rad );
  81          ellipse[e_cnt] = sr0( tox, toy, toz );
  82       }
  83       if( ( NORB < 0 ) && ( t_ang > ( ANG2-DELTANG ) ) ) {
  84          gdImageFilledPolygon( im, ellipse, NELIP, black );
  85       }
  86       gdImagePolygon( im, ellipse, NELIP, ecolor );
  87 
  88 
  89       for( orb=0 ; orb < norb ; orb++ ) {
  90          // orbit spot on left
  91          int    tcolor = tc[orb]; 
  92          double toa = angle_rad +  DEG2RAD( ta[orb] ) ;
  93          double tos = step * td[ orb ] ;                 // step size
  94          double tor = tos * cos( toa );
  95          double toy = tos * sin( toa );
  96          double tox = -(major+tor)*sin( angle_rad );
  97          double toz = -(major+tor)*cos( angle_rad );
  98          gdPoint pto = sr0( tox, toy, toz );
  99          gdImageFilledEllipse( im, pto.x, pto.y, ORBWIDTH, ORBWIDTH, tcolor);
 100          
 101          // orbit spot on right
 102          toa = -angle_rad +  DEG2RAD( ta[orb] ) ;
 103          tos = step * td[ orb ] ;                 // step size
 104          tor = tos * cos( toa );
 105          toy = tos * sin( toa );
 106          tox = -(major+tor)*sin( -angle_rad );
 107          toz = -(major+tor)*cos( -angle_rad );
 108          pto = sr0( tox, toy, toz );
 109          gdImageFilledEllipse( im, pto.x, pto.y, ORBWIDTH, ORBWIDTH, tcolor);
 110       }  
 111    }      
 112    drawearth();
 113 
 114    if( NORB > 0 ) {
 115       // draw the rest of the center orbit
 116       for( t_ang=ANG2 ; t_ang < 360.0-ANG2 ; t_ang += DELTANG ) {
 117          double  angle_rad=DEG2RAD( t_ang );
 118          double  tox = -major*sin( angle_rad );
 119          double  toz = -major*cos( angle_rad );
 120          gdPoint pto = sr0( tox, 0.0, toz );
 121          gdImageFilledEllipse( im, pto.x, pto.y, ORBWIDTH, ORBWIDTH, tc[0]);
 122       }
 123    }
 124    sprintf( bottom, "%5.0fkm spacing between orbits", 6378.0*step/re );
 125 
 126    frameend();
 127    displayend();
 128    return 0;
 129 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-05-12 03:45:56, 11.6 KB) [[attachment:ap01.c]]
  • [get | view] (2009-05-12 20:57:15, 11.1 KB) [[attachment:ap02.c]]
  • [get | view] (2021-06-19 05:05:20, 853.5 KB) [[attachment:ap02.png]]
  • [get | view] (2009-05-11 08:39:41, 1.4 KB) [[attachment:t01.c]]
  • [get | view] (2009-05-11 02:49:58, 14.3 KB) [[attachment:t01.gif]]
  • [get | view] (2009-05-11 08:39:31, 4.0 KB) [[attachment:t04.c]]
  • [get | view] (2009-05-11 02:50:13, 24.3 KB) [[attachment:t04.gif]]
  • [get | view] (2009-05-11 08:39:10, 4.0 KB) [[attachment:t08.c]]
  • [get | view] (2009-05-11 02:50:25, 29.6 KB) [[attachment:t08.gif]]
  • [get | view] (2009-05-11 02:53:25, 34.8 KB) [[attachment:t12.gif]]
  • [get | view] (2009-05-11 08:38:55, 4.0 KB) [[attachment:t16.c]]
  • [get | view] (2009-05-11 02:53:12, 38.0 KB) [[attachment:t16.gif]]
  • [get | view] (2009-05-11 08:38:44, 4.0 KB) [[attachment:t20.c]]
  • [get | view] (2009-05-11 02:52:57, 39.6 KB) [[attachment:t20.gif]]
  • [get | view] (2009-05-11 08:38:32, 4.0 KB) [[attachment:t24.c]]
  • [get | view] (2009-05-11 02:52:39, 44.0 KB) [[attachment:t24.gif]]
  • [get | view] (2009-05-11 08:37:48, 4.0 KB) [[attachment:t25.c]]
  • [get | view] (2009-05-11 02:52:29, 41.5 KB) [[attachment:t25.gif]]
  • [get | view] (2009-05-11 08:38:21, 3.4 KB) [[attachment:t26.c]]
  • [get | view] (2009-05-11 02:52:12, 28.0 KB) [[attachment:t26.gif]]
  • [get | view] (2009-05-11 08:37:25, 2.5 KB) [[attachment:t27.c]]
  • [get | view] (2009-05-11 02:51:59, 25.8 KB) [[attachment:t27.gif]]
  • [get | view] (2009-05-11 08:37:13, 2.5 KB) [[attachment:t28.c]]
  • [get | view] (2009-05-11 02:51:34, 18.5 KB) [[attachment:t28.gif]]
  • [get | view] (2009-05-11 08:37:01, 1.4 KB) [[attachment:t41.c]]
  • [get | view] (2009-05-11 02:51:19, 11.4 KB) [[attachment:t41.gif]]
  • [get | view] (2009-05-11 08:36:46, 3.6 KB) [[attachment:t42.c]]
  • [get | view] (2009-05-11 02:50:49, 5.3 KB) [[attachment:t42.gif]]
  • [get | view] (2009-05-11 08:36:31, 13.4 KB) [[attachment:tor00.hc]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.