Orbital elements: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: added REXX version 2.) |
m (→version 2: simplified the REXX code by eliding the need to use a slash separator for vectors, other improvements.) |
||
Line 940:
<lang rexx>/*REXX pgm converts orbital elements ──► orbital state vectors (angles are in radians).*/
numeric digits length(pi() ) - 1 /*limited to pi len, but show 1/3 digs.*/
parse value orbV(1, 0.1, 0, 355 / (113*6), 0, 0)
say ' position:' show(position)
say ' speed:' show(speed)
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
absV: procedure; parse arg x
divV: procedure; parse arg x
mulV: procedure; parse arg x
show: procedure; parse arg a
fmt: procedure; parse arg #;
pi: pi=3.1415926535897932384626433832795028841971693993751058209749445923; return pi
rot: procedure; parse arg i,j,$; return MA(i,
r2r: return arg(1) // (pi() * 2)
/*──────────────────────────────────────────────────────────────────────────────────────*/
orbV: procedure; parse arg semiMaj, eccentricity, inclination, node, periapsis, anomaly
parse value rot(i,
parse value rot(i,
if eccentricity=1 then L= 2
else L= 1 - eccentricity**2
Line 965:
r= L / (1 + eccentricity * c)
@= s*r**2 / L; speed= MA(i, @*c - r*s, j, @*s + r*c)
return mulV( MA(i,
/*──────────────────────────────────────────────────────────────────────────────────────*/
MA: procedure; parse arg x
/*──────────────────────────────────────────────────────────────────────────────────────*/
cos: procedure; parse arg x; x= r2r(x); a=abs(x); hpi= pi * .5
|