Orbital elements: Difference between revisions
Content added Content deleted
m (→version 2: added a more description origin.) |
m (→version 2: optimized some functions, standarized the output (width).) |
||
Line 944: | Line 944: | ||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
orbV: procedure; parse arg semiMaj, eccentricity, inclination, node, periapsis, anomaly |
orbV: procedure; parse arg semiMaj, eccentricity, inclination, node, periapsis, anomaly |
||
i= 1 0 0; j= 0 1 0; k= 0 0 1 |
i= 1 0 0; j= 0 1 0; k= 0 0 1 /*define the I, J, K vectors.*/ |
||
parse value rot(i, j, node) with i '~' j /*rotate ascending node longitude.*/ |
parse value rot(i, j, node) with i '~' j /*rotate ascending node longitude.*/ |
||
parse value rot(j, k, inclination) with j '~' /*rotate the inclination. */ |
parse value rot(j, k, inclination) with j '~' /*rotate the inclination. */ |
||
Line 961: | Line 961: | ||
mulV: procedure; parse arg x y z, d; return (x * d) (y * d) (z * d) |
mulV: procedure; parse arg x y z, d; return (x * d) (y * d) (z * d) |
||
show: procedure; parse arg a b c; return '('fmt(a)"," fmt(b)',' fmt(c)")" |
show: procedure; parse arg a b c; return '('fmt(a)"," fmt(b)',' fmt(c)")" |
||
fmt: procedure; parse arg #; return left('',#>=0) |
fmt: procedure; parse arg #; return left( left('', #>=0)#/1, digits()%3) |
||
MA: procedure; parse arg x y z,a,xx yy zz,b; return (x*a+xx*b) (y*a+yy*b) (z*a+zz*b) |
MA: procedure; parse arg x y z,a,xx yy zz,b; return (x*a+xx*b) (y*a+yy*b) (z*a+zz*b) |
||
pi: pi= 3.1415926535897932384626433832795028841971693993751058209749445923; return pi |
pi: pi= 3.1415926535897932384626433832795028841971693993751058209749445923; return pi |
||
Line 968: | Line 968: | ||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
cos: procedure; parse arg x; x= r2r(x); a=abs(x); hpi= pi * .5 |
cos: procedure; parse arg x; x= r2r(x); a=abs(x); hpi= pi * .5 |
||
numeric fuzz min(6, digits() - 3); if a=pi |
numeric fuzz min(6, digits() - 3); if a=pi then return -1 |
||
if a=hpi | a=hpi*3 then return 0; if a=pi |
if a=hpi | a=hpi*3 then return 0; if a=pi / 3 then return .5 |
||
if a=pi |
if a=pi * 2 / 3 then return -.5; return .sinCos(1, -1) |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
sin: procedure; parse arg x; x=r2r(x); numeric fuzz min(5, max(1, digits() -3)) |
sin: procedure; parse arg x; x=r2r(x); numeric fuzz min(5, max(1, digits() -3)) |
||
Line 985: | Line 985: | ||
{{out|output|text= when using the default internal inputs:}} |
{{out|output|text= when using the default internal inputs:}} |
||
<pre> |
<pre> |
||
position: ( 0. |
position: ( 0.779422843398679832, 0.450000034653684237, 0 ) |
||
speed: (-0. |
speed: (-0.552770840960443759, 0.957427083179761535, 0 ) |
||
</pre> |
</pre> |
||