Attachment 'tor08.c'

Download

   1 // tor08.c
   2 // v0.1 KHL 2009-04-21
   3 // gcc -o tor08 tor08.c -lm -lgd ; ./tor08
   4 // static drawing, though slow to compute
   5 // earth and toroid around orbit
   6 
   7 #define NAME     "tor08"
   8 #define NORB1     5
   9 #define NORB2     9
  10 #define DELTANG 0.2
  11 #define ORBWIDTH  5
  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    singlestart(NAME);
  28    framestart(    90, "M288, center + 4 toroid orbits");
  29    torstart();
  30 
  31    // draw back portion of the orbit toroid
  32   
  33    double acolor =  0.0 ;
  34    norb = NORB1 ;
  35    for( t_ang=ANG0 ; t_ang < ANG2 ; t_ang += DELTANG ) {
  36 
  37       double ecolor ;
  38       if( acolor < 0.5 ) { ecolor = gray ; }
  39       else {
  40          ecolor = lgray ;
  41          if( acolor > 14.5 ) { acolor -= 15.0 ; }
  42       }
  43       acolor += DELTANG ;
  44 
  45       double angle_rad=DEG2RAD( t_ang );
  46 
  47       // ellipse disk - since it is at an angle, we will have to draw it
  48       // as a filled polygon
  49     
  50       // ellipse disk on left
  51       for( e_cnt=0 ; e_cnt < NELIP ; e_cnt++ ) {
  52          double toa = angle_rad + (2.0*PI*e_cnt)/NELIP  ;
  53          double tos = td[ norb-1 ] * step ;                 // step size
  54          double tor = tos * cos( toa );
  55          double toy = tos * sin( toa );
  56          double tox = -(major+tor)*sin( angle_rad );
  57 	 double toz = -(major+tor)*cos( angle_rad );
  58 	 ellipse[e_cnt] = sr0( tox, toy, toz );
  59       }
  60       gdImagePolygon( im, ellipse, NELIP, ecolor );
  61 
  62       // ellipse disk on right
  63       for( e_cnt=0 ; e_cnt < NELIP ; e_cnt++ ) {
  64          double toa = -angle_rad + (2.0*PI*e_cnt)/NELIP  ;
  65          double tos = td[ norb-1 ] * step ;                 // step size
  66          double tor = tos * cos( toa );
  67          double toy = tos * sin( toa );
  68          double tox = -(major+tor)*sin( -angle_rad );
  69          double toz = -(major+tor)*cos( -angle_rad );
  70          ellipse[e_cnt] = sr0( tox, toy, toz );
  71       }
  72       gdImagePolygon( im, ellipse, NELIP, ecolor );
  73 
  74 
  75       for( orb=0 ; orb < norb ; orb++ ) {
  76          // orbit spot on left
  77          int    tcolor = tc[orb]; 
  78          double toa = angle_rad +  DEG2RAD( ta[orb] ) ;
  79          double tos = step * td[ orb ] ;                 // step size
  80          double tor = tos * cos( toa );
  81          double toy = tos * sin( toa );
  82          double tox = -(major+tor)*sin( angle_rad );
  83          double toz = -(major+tor)*cos( angle_rad );
  84          gdPoint pto = sr0( tox, toy, toz );
  85          gdImageFilledEllipse( im, pto.x, pto.y, ORBWIDTH, ORBWIDTH, tcolor);
  86          
  87          // orbit spot on right
  88          toa = -angle_rad +  DEG2RAD( ta[orb] ) ;
  89          tos = step * td[ orb ] ;                 // step size
  90          tor = tos * cos( toa );
  91          toy = tos * sin( toa );
  92          tox = -(major+tor)*sin( -angle_rad );
  93          toz = -(major+tor)*cos( -angle_rad );
  94          pto = sr0( tox, toy, toz );
  95          gdImageFilledEllipse( im, pto.x, pto.y, ORBWIDTH, ORBWIDTH, tcolor);
  96       }  
  97    }      
  98    drawearth();
  99 
 100    // draw the rest of the center orbit
 101    for( t_ang=ANG2 ; t_ang < 360.0-ANG2 ; t_ang += DELTANG ) {
 102       double  angle_rad=DEG2RAD( t_ang );
 103       double  tox = -major*sin( angle_rad );
 104       double  toz = -major*cos( angle_rad );
 105       gdPoint pto = sr0( tox, 0.0, toz );
 106       gdImageFilledEllipse( im, pto.x, pto.y, ORBWIDTH, ORBWIDTH, tc[0]);
 107    }
 108 
 109    frameend();
 110    return 0;
 111 }

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] (2013-02-12 15:26:57, 228.9 KB) [[attachment:A0_title.jpg]]
  • [get | view] (2013-02-12 15:35:39, 912.5 KB) [[attachment:B0_serversatV3a.png]]
  • [get | view] (2013-02-12 15:36:48, 1976.2 KB) [[attachment:C0_world_marble.png]]
  • [get | view] (2013-02-12 15:36:23, 1602.0 KB) [[attachment:C3_energy.png]]
  • [get | view] (2013-02-12 15:33:18, 469.6 KB) [[attachment:E0_m288xx.png]]
  • [get | view] (2013-02-12 15:32:48, 59.2 KB) [[attachment:E3_crosser.png]]
  • [get | view] (2013-02-12 15:32:06, 405.6 KB) [[attachment:H0_toroid.png]]
  • [get | view] (2013-02-12 15:34:51, 97.8 KB) [[attachment:I0_echrome.png]]
  • [get | view] (2013-02-12 15:34:08, 356.0 KB) [[attachment:J3_turn_tidal.png]]
  • [get | view] (2013-02-12 15:33:46, 281.9 KB) [[attachment:K0_lighteccentric.png]]
  • [get | view] (2013-02-12 15:31:33, 454.9 KB) [[attachment:M0_temperature.png]]
  • [get | view] (2013-02-12 15:35:14, 101.8 KB) [[attachment:M3_deploy.png]]
  • [get | view] (2013-02-12 15:30:15, 700.1 KB) [[attachment:Q0_phasedarray.png]]
  • [get | view] (2013-02-12 15:29:44, 466.0 KB) [[attachment:Q3_arrayspace.png]]
  • [get | view] (2013-02-12 15:31:06, 488.4 KB) [[attachment:R0_radiation.png]]
  • [get | view] (2013-02-12 15:30:42, 281.4 KB) [[attachment:R3_radiation.png]]
  • [get | view] (2013-02-12 15:27:28, 506.1 KB) [[attachment:S0_costdrop.png]]
  • [get | view] (2013-02-12 15:28:49, 3693.6 KB) [[attachment:U0_radar.png]]
  • [get | view] (2013-02-12 15:27:55, 416.5 KB) [[attachment:U3_rocketbody.png]]
  • [get | view] (2013-02-16 04:59:50, 14.8 KB) [[attachment:a6.c]]
  • [get | view] (2013-02-16 04:59:58, 14.6 KB) [[attachment:a7.c]]
  • [get | view] (2013-02-16 03:52:04, 16.9 KB) [[attachment:ar06.c]]
  • [get | view] (2013-02-15 23:11:57, 1.7 KB) [[attachment:crosser.gp]]
  • [get | view] (2013-02-15 23:11:40, 2.3 KB) [[attachment:crosser.pl]]
  • [get | view] (2013-02-16 04:30:17, 2.0 KB) [[attachment:darkside0.gp]]
  • [get | view] (2013-02-16 15:28:29, 2.3 KB) [[attachment:darkside0.pl]]
  • [get | view] (2013-02-16 03:38:30, 9.3 KB) [[attachment:echrome04.c]]
  • [get | view] (2013-02-16 15:29:15, 5.7 KB) [[attachment:insertrb.pl]]
  • [get | view] (2013-02-16 15:37:24, 1.9 KB) [[attachment:lj2.gp]]
  • [get | view] (2013-02-16 15:37:08, 2.3 KB) [[attachment:lj2.pl]]
  • [get | view] (2013-02-16 04:14:19, 5.1 KB) [[attachment:orbit04w.c]]
  • [get | view] (2013-02-16 04:19:08, 9.1 KB) [[attachment:pa03.c]]
  • [get | view] (2013-02-16 04:19:19, 9.1 KB) [[attachment:pa04.c]]
  • [get | view] (2013-02-12 18:22:40, 5.3 KB) [[attachment:pc02.c]]
  • [get | view] (2013-02-16 15:29:37, 2.0 KB) [[attachment:rb.gp]]
  • [get | view] (2013-02-16 02:50:27, 6.0 KB) [[attachment:sh01.c]]
  • [get | view] (2013-02-13 23:22:32, 13918.1 KB) [[attachment:ss.pdf]]
  • [get | view] (2013-02-13 23:21:58, 23.3 KB) [[attachment:ss.tex]]
  • [get | view] (2013-02-16 04:07:31, 24.1 KB) [[attachment:ss6a.c]]
  • [get | view] (2013-02-16 04:12:13, 3.4 KB) [[attachment:tor08.c]]
 All files | Selected Files: delete move to page

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