Jump to content

Horizontal sundial calculations: Difference between revisions

→‎{{header|REXX}}: fixed the program to correctly calculate the sundial hour line angle when the sun hour angle is greated than a right angle.
m (→‎{{header|REXX}}: fixed a typo.)
(→‎{{header|REXX}}: fixed the program to correctly calculate the sundial hour line angle when the sun hour angle is greated than a right angle.)
Line 2,033:
<br>so these as well as &nbsp; '''pi''' &nbsp; were added to this program.
 
The &nbsp; ''legal meridian''' &nbsp; is calculated instead of relying on a specified amount.
 
No attempt was made to explain the inner workings of the trigonometric functions.
Line 2,056:
say indent center(' ', w1) center("sun hour", w2) center('dial hour' , w3)
say indent center('hour', w1) center("angle" , w2) center('line angle', w3)
call sep /*to help a one-eyedone─eyed pirate's eyeball. */
do h=-6 to 6 /*Okey dokey then, now let's show stuff*/
select
Line 2,066:
hra=15 * h - lng + mer /*calculate sun hour angle (in degrees)*/
hla=r2d( Atan(sineLat * tan( d2r(hra)))) /*this is the heavy lifting calculation*/
if abs(hra)>90 then hla=hla + 180*sign(hra*lat) /*adjust for negative angle. */
say indent center(hc, w1) right(format(hra, ,1), w2) right(format(hla, ,1), w3)
end /*h*/
call sep /*to help a one-eyedone─eyed pirate's eyeball. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 2,086 ⟶ 2,087:
/*──────────────────────────────────────────────────────────────────────────────────────*/
Asin: procedure; parse arg x; if x<-1 | x>1 then call AsinErr; s=x*x
if abs(x)>=sqrt(2)*.45 then return sign(x) * Acos(sqrt(1-s)); z=x; o=x; p=z
do j=2 by 2; o=o*s*(j-1)/j; z=z+o/(j+1); if z=p then leave; p=z; end; return z
/*──────────────────────────────────────────────────────────────────────────────────────*/
Cookies help us deliver our services. By using our services, you agree to our use of cookies.