Horizontal sundial calculations: Difference between revisions
Content added Content deleted
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: | Line 2,033: | ||
<br>so these as well as '''pi''' were added to this program. |
<br>so these as well as '''pi''' were added to this program. |
||
The ''legal meridian |
The ''legal meridian'' is calculated instead of relying on a specified amount. |
||
No attempt was made to explain the inner workings of the trigonometric functions. |
No attempt was made to explain the inner workings of the trigonometric functions. |
||
Line 2,056: | Line 2,056: | ||
say indent center(' ', w1) center("sun hour", w2) center('dial hour' , w3) |
say indent center(' ', w1) center("sun hour", w2) center('dial hour' , w3) |
||
say indent center('hour', w1) center("angle" , w2) center('line angle', w3) |
say indent center('hour', w1) center("angle" , w2) center('line angle', w3) |
||
call sep /*to help a |
call sep /*to help a one─eyed pirate's eyeball. */ |
||
do h=-6 to 6 /*Okey dokey then, now let's show stuff*/ |
do h=-6 to 6 /*Okey dokey then, now let's show stuff*/ |
||
select |
select |
||
Line 2,066: | Line 2,066: | ||
hra=15 * h - lng + mer /*calculate sun hour angle (in degrees)*/ |
hra=15 * h - lng + mer /*calculate sun hour angle (in degrees)*/ |
||
hla=r2d( Atan(sineLat * tan( d2r(hra)))) /*this is the heavy lifting calculation*/ |
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) |
say indent center(hc, w1) right(format(hra, ,1), w2) right(format(hla, ,1), w3) |
||
end /*h*/ |
end /*h*/ |
||
call sep /*to help a |
call sep /*to help a one─eyed pirate's eyeball. */ |
||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
Line 2,086: | Line 2,087: | ||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
Asin: procedure; parse arg x; if x<-1 | x>1 then call AsinErr; s=x*x |
Asin: procedure; parse arg x; if x<-1 | x>1 then call AsinErr; s=x*x |
||
if abs(x)>=sqrt(2)*. |
if abs(x)>=sqrt(2)*.5 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 |
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 |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |