Orbital elements: Difference between revisions

→‎{{header|ooRexx}}: Numeric Digits 16 + added Perl6 alternate test, courtesy GS
(→‎version 2: added input from the Perl 6 entry, added detailed output to show what data (orbital elements) are being used, added a title for the output.)
(→‎{{header|ooRexx}}: Numeric Digits 16 + added Perl6 alternate test, courtesy GS)
Line 457:
Numeric Digits 16
ps = orbitalStateVectors(1.0, 0.1, 0.0, 355.0 / (113.0 * 6.0), 0.0, 0.0)
Say "Position :" ps~x~tostring
Say "Speed :" ps~y~tostring
Say 'Perl6:'
pi=rxCalcpi(16)
ps=orbitalStateVectors(1,.1,pi/18,pi/6,pi/4,0) /*Perl6*/
Say "Position :" ps~x~tostring
Say "Speed :" ps~y~tostring
Line 478 ⟶ 483:
::method print
expose x y z
Numeric Digits 16
Say 'Vector:'||x'/'y'/'z
 
Line 486 ⟶ 492:
::method abs
expose x y z
Numeric Digits 16
Return rxCalcsqrt(x**2+y**2+z**2,16)
 
::method '*'
expose x y z
Parse Arg f
Numeric Digits 16
Return .vector~new(x*f,y*f,z*f)
 
Line 496 ⟶ 504:
expose x y z
Parse Arg f
Numeric Digits 16
Return .vector~new(x/f,y/f,z/f)
 
Line 501 ⟶ 510:
expose x y z
Use Arg v2
Numeric Digits 16
Return .vector~new(x+v2~x,y+v2~y,z+v2~z)
 
Line 510 ⟶ 520:
argumentOfPeriapsis,,
trueAnomaly
Numeric Digits 16
i = .vector~new(1, 0, 0)
j = .vector~new(0, 1, 0)
Line 531 ⟶ 542:
speed=mulAdd(i,rprime*c-r*s,j,rprime*s+r*c)
speed=speed~'/'(speed~abs)
speed=speed~'*'(rxCalcsqrt(2.0/r-1.0/semimajorAxis,16))
/*
position~print
speed~print
*/
Return .v2~new(position,speed)
 
::routine muladd
Use Arg v1,x1,v2,x2
Numeric Digits 16
w1=v1~'*'(x1)
w2=v2~'*'(x2)
Line 546 ⟶ 554:
::routine rotate
Use Arg i,j,alpha
Numeric Digits 16
xx=mulAdd(i,rxCalccos(alpha,16,'R'),j,rxCalcsin(alpha,16,'R'))
yy=mulAdd(i,-rxCalcsin(alpha,16,'R'),j,rxCalccos(alpha,16,'R'))
Line 554 ⟶ 563:
 
{{out}}
<pre>Position : (0.7794228447794228433986798,0.4500000354500000346536842,0)
Speed : (-0.5527708425527708409604436,0.9574270859574270831797613,0)</pre>
Perl6:
Position : (0.2377712839822067,0.8609602616977158,0.1105090235720755)
Speed : (-1.061933017480060,0.2758500205692495,0.1357470248655981)</pre>
 
=={{header|Perl}}==
2,295

edits