Orbital elements: Difference between revisions

m
→‎version 2: used a simpler version of negative one.
(Added Algol W)
m (→‎version 2: used a simpler version of negative one.)
Line 1,356:
numeric digits length( pi() ) - length(.) /*limited to pi len, but show 1/3 digs.*/
call orbV 1, .1, 0, 355/113/6, 0, 0 /*orbital elements taken from: Java */
call orbV 1, .1, pi/18, pi/6, pi/4, 0 /* " " " " Raku Perl 6 */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 1,393:
/*──────────────────────────────────────────────────────────────────────────────────────*/
cos: procedure; arg x; x= r2r(x); if x=0 then return 1; a= abs(x); Hpi= pi * .5
numeric fuzz min(6, digits() - 3); if a=pi then return '-1'
if a=Hpi | a=Hpi*3 then return 0; if a=pi / 3 then return .5
if a=pi * 2 / 3 then return '-.5'; $= x * x; return .sinCos(1, '-1')
/*──────────────────────────────────────────────────────────────────────────────────────*/
sin: procedure; arg x; x= r2r(x); numeric fuzz min(5, max(1, digits() - 3) )
if x=0 then return 0; if x=pi*.5 then return 1; if x==pi*1.5 then return '-1'
if abs(x)=pi then return 0; $= x * x; return .sinCos(x, 1)
/*──────────────────────────────────────────────────────────────────────────────────────*/