Orbital elements: Difference between revisions
Content added Content deleted
m (→{{header|Sidef}}: simplified the code to use the built-in Matrix class) |
|||
Line 1,174:
true_anomaly
) {
var (i, j, k) = (
Matrix([0, 1, 0]),
Matrix([0, 0, 1]),
)
func muladd(v1, x1, v2, x2) {
(v1
}
Line 1,192 ⟶ 1,195:
rotate(\i, \j, argument_of_periapsis)
var l = (eccentricity == 1
var (c, s) = with(true_anomaly) { (.cos, .sin) }
Line 1,199 ⟶ 1,202:
var r = l/(1 + eccentricity*c)
var rprime = (s * r**2 / l)
var position = muladd(i, c, j, s)
var speed = muladd(i, rprime*c - r*s, j, rprime*s + r*c)
speed
speed
struct Result { position, speed }
Result([position,speed].map {|v|
}
for args in ([
var r = orbital_state_vectors(▼
[1, 0.1, 0, 355/(113*6), 0, 0],
[1, 0.1, Num.pi/18, Num.pi/6, Num.pi/4, 0]
]) {
▲ var r = orbital_state_vectors(args...)
say "Arguments: #{args}:"
say "Position : #{r.position}"
say "Speed : #{r.speed}\n"
}</lang>
{{out}}
<pre>
Arguments: [1, 1/10, 0, 355/678, 0, 0]:
Position : [0.779422843398679832042176328223663037464703527986, 0.450000034653684237432302249506712706822033851071, 0]
Speed : [-0.552770840960443759673279062314259546277084494097, 0.957427083179761535246200368614952095349966503287, 0]
Arguments: [1, 1/10, 0.174532925199432957692369076848861271344287188854, 0.523598775598298873077107230546583814032861566563, 0.785398163397448309615660845819875721049292349844, 0]:
Position : [0.23777128398220654779107184959165027147748809404, 0.860960261697715834668966272382699039216399966872, 0.110509023572075562109405412890808505271310143909]
Speed : [-1.06193301748006004757467368094494935655538772696, 0.275850020569249507846452830330085489348356659642, 0.135747024865598167166145512759280712986072818844]
</pre>
=={{header|zkl}}==
|