## Attachment 'locus01.pl'

Download

#!/usr/local/bin/perl
# draw orbit with semimajor axis 1,  radius eccentricity e
# then rotate by mean anomaly

use Math::Trig;

my   \$pi           = 4.0*atan(1.0)      ;
my   \$radian       = \$pi / 180.0        ;
my   @ea = (1e-3, 3e-3, 1e-2,  3e-2, 1e-1, 3e-1 );
## my   @ea = ( 1e-2 );
my   \$da = 0.5 ;
## my   \$da = 15.0 ;

## printf "  theta  sin   cos  r      xr    yr    ce    se" ;
## printf "    EE     M      x         y\n";

## foreach my \$e ( @ea ) { printf "%11.3e   ", \$e } ; printf  "\n" ;

# compute from apogee to apogee
for( my \$an  = -180.0 ; \$an < 180.00001 ; \$an += \$da ) {
my \$theta = \$radian * \$an ;
\$s = sin( \$theta );
\$c = cos( \$theta );
foreach my \$e ( @ea ) {
my \$rr = (1.0-\$e*\$e) / (1.0 + \$e*\$c );
my \$xr = -\$rr * \$s ;
my \$yr =  \$rr * \$c ;

# it is difficult to compute E with the standard acos(\$ce)
# formula, because quadrant information is lost.
#
# However, if we compute both the cosine of E (\$ce)  and the
# sin (\$se), we can use the atan2 function to get \$E, since
# \$ce and \$se together specify the quadrant.

my \$ce = ( \$e + \$c ) / ( 1.0 + \$e*\$c );
my \$se = sqrt( 1.0 - \$e*\$e ) * \$s / ( 1.0 + \$e*\$c ) ;

my \$E  = atan2( \$se, \$ce );

my \$M = \$E - \$e * sin( \$E );

my \$cm = cos( \$M );
my \$sm = sin( \$M );

# rotate \$xr, \$yr by angle \$M

my \$x = ( \$cm * \$xr + \$sm * \$yr ) / \$e ;
my \$y = ( \$cm * \$yr - \$sm * \$xr - 1.0 ) / \$e ;

## my \$x = ( \$cm * \$xr + \$sm * \$yr ) ;
## my \$y = ( \$cm * \$yr - \$sm * \$xr ) ;

##  printf "%7.3f%6.2f%6.2f%6.3f%6.2f%6.2f%6.2f%6.2f%7.3f%7.3f%10.2e%10.2e",
##          \$theta, \$s,  \$c, \$rr, \$xr, \$yr, \$ce, \$se,  \$E,  \$M,   \$x,   \$y ;
printf "%7.3f%7.3f",  \$x, \$y ;
}
printf "\n";
}

## 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-04-01 06:24:24, 1118.9 KB) [[attachment:Anomaly.png]]
• [get | view] (2011-04-04 06:37:30, 59.8 KB) [[attachment:locus01.dat]]
• [get | view] (2011-04-04 06:38:24, 1.9 KB) [[attachment:locus01.gp]]
• [get | view] (2011-04-04 06:38:11, 1.7 KB) [[attachment:locus01.pl]]
• [get | view] (2011-04-04 06:37:51, 20.2 KB) [[attachment:locus01.png]]
All files | Selected Files: delete move to page

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