Attachment 'a2.c'

Download

   1 // a2.c  space elevator radar slab
   2 //  cc -o a2 a2.c -lm
   3 //  ./a2 > a2.txt
   4 
   5 #include <stdlib.h>
   6 #include <stdio.h>
   7 #include <math.h>
   8 
   9 #define  RSEMAX  2400.0  // space elevator maximum
  10 #define  PLAT      50.0  // platform altitude
  11 #define  A0       200.0  // minimum space debris altitude
  12 #define  A1       700.0  // Bradley minimum space debris altitude
  13 #define  A2      1700.0  // Bradley maximum space debris altitude
  14 #define  A3      2200.0  // maximum space debris altitude
  15 #define  REY0    -300.0  // minimum earth circle
  16 #define  RE      6378.0  // Earth equatorial radius
  17 #define  DP       100    // points per one side of arc
  18 #define  MU    398600.44 // gravitational parameter
  19 
  20 void orbnum( double a ) {
  21    double  y = RE+PLAT ;
  22    double  x = sqrt( (RE+a)*(RE+a) - y*y );
  23    double  v = sqrt( MU/(RE+a) );
  24    double  s = x / v ;
  25    double  m = s / 60.0 ; 
  26    double  b = atan2( x, y );
  27    double  c = b*(RE+a)*(RE+a)-0.5*x*y ;
  28    printf( "#||%7.0f ||%6.0f ||%8.2f ||%8.2f ||%7.2f ||%12.4e ||\n",
  29              a, x, v, s, m, c );
  30 }
  31 
  32 int  main() { 
  33    double   le  = acos((RE+REY0)/ RE    ) ; // longitude of earth circle
  34    double   la0 = acos((RE+REY0)/(RE+A0)) ; // longitude A0 horizon
  35    double   la1 = acos((RE+REY0)/(RE+A1)) ; // longitude A1 horizon
  36    double   la2 = acos((RE+REY0)/(RE+A2)) ; // longitude A2 horizon
  37    double   la3 = acos((RE+REY0)/(RE+A3)) ; // longitude A3 horizon
  38    double   r2d = 45.0/atan(1.0) ;
  39 
  40    double   x, y ;
  41 
  42    double   xa3 = (RE+A3)*sin( la3 )  ;
  43    int        i ;
  44 
  45    for( i=-DP ; i <=DP ; i++ ) {
  46       double f  = ((double) i )/((double) DP) ;
  47 
  48       // radar horizon line
  49       x = f * xa3 ;
  50       y = PLAT    ;
  51       printf( "%7.1f%7.1f", x, y );
  52 
  53       // earth radius
  54       x = RE * sin( le*f ) ;
  55       y = RE * cos( le*f ) - RE   ;
  56       printf( "%8.1f%7.1f", x, y );
  57 
  58       // A0
  59       x = (RE+A0)*sin( la0*f ) ;
  60       y = (RE+A0)*cos( la0*f ) - RE ;
  61       printf( "%8.1f%7.1f", x, y );
  62 
  63       // A1
  64       x = (RE+A1)*sin( la1*f ) ;
  65       y = (RE+A1)*cos( la1*f ) - RE ;
  66       printf( "%8.1f%7.1f", x, y );
  67 
  68       // A2
  69       x = (RE+A2)*sin( la2*f ) ;
  70       y = (RE+A2)*cos( la2*f ) - RE ;
  71       printf( "%8.1f%7.1f", x, y );
  72 
  73       // A3
  74       x = (RE+A3)*sin( la3*f ) ;
  75       y = (RE+A3)*cos( la3*f ) - RE ;
  76       printf( "%8.1f%7.1f", x, y );
  77 
  78       // space elevator
  79       y = PLAT + (RSEMAX-PLAT)*fabs(f);
  80       printf( " 0.0 %7.1f", y );
  81 
  82       printf( "\n");
  83    }
  84 
  85    printf( "#%8.2f%8.2f%8.2f%8.2f\n", r2d*la0, r2d*la1, r2d*la2, r2d*la3 );
  86 
  87    for( i=100 ; i<2300 ; i+=200 ) orbnum( (double) i ) ;
  88 }
  89   

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] (2011-06-17 01:20:55, 21.3 KB) [[attachment:a1.png]]
  • [get | view] (2011-06-17 04:48:08, 2.5 KB) [[attachment:a2.c]]
  • [get | view] (2011-06-17 04:48:33, 0.9 KB) [[attachment:a2.gp]]
  • [get | view] (2011-06-17 04:47:49, 19.7 KB) [[attachment:a2.png]]
 All files | Selected Files: delete move to page

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