Orbital elements: Difference between revisions

Content added Content deleted
(Add Ada)
(J)
Line 739: Line 739:
</pre>
</pre>


=={{header|J}}==
{{trans|Raku}}<lang J>NB. euler rotation matrix le,ft hand rule
NB. x: axis (0, 1 or 2), y: angle in radians
R=: {{ ((2 1,:1 2) o.(,-)y*_1^2|x)(,&.>/~0 1 2-.x)} =i.3 }}
X=: +/ .* NB. inner product

orbitalStateVectors=: {{
NB. a: semi-major axis
NB. e: eccentricity
NB. i: inclination
NB. Om: Longitude of the ascending node
NB. w: argument of Periapsis (the other "omega")
NB. f: true anomaly
'a e i Om w f'=: y
l=: a*2:`]@.*1-*:e
'c s'=. 2{.,F=: 2 R f
ra=: l % 1+ e*c
rp=: s*ra*ra%l
ijk=: F X (2 R w)X(0 R i)X(2 R Om)
position=: ra*{.ijk
speed=: (%:(2%ra)-%a)*(%%:@X~) (rp,ra,0) X ijk
position,:speed
}}</lang>

Task example:<lang J> orbitalStateVectors 1 0.1 0 355r678 0 0
0.779423 0.45 0
_0.552771 0.957427 0</lang>
=={{header|Java}}==
=={{header|Java}}==
{{trans|Kotlin}}
{{trans|Kotlin}}