Horizontal sundial calculations: Difference between revisions
Content added Content deleted
(→{{header|Forth}}: Prevent unexpected sign change in output) |
|||
Line 1,326: | Line 1,326: | ||
5 PM 75.500 -18.451 |
5 PM 75.500 -18.451 |
||
6 PM 90.500 -95.775 |
6 PM 90.500 -95.775 |
||
</pre> |
|||
=={{header|Phix}}== |
|||
Copy of [[Horizontal_sundial_calculations#Euphoria|Euphoria]] |
|||
<lang Phix>atom lat = prompt_number("Enter Latitude: ",{}) |
|||
atom lng = prompt_number("Enter Longitude: ",{}) |
|||
atom lm = prompt_number("Enter Legal Meridian: ",{}) |
|||
puts(1,'\n') |
|||
atom ha, hla |
|||
function Deg2Rad(atom degrees) |
|||
return degrees * PI / 180 |
|||
end function |
|||
function Rad2Deg(atom radians) |
|||
return radians * 180 / PI |
|||
end function |
|||
function atan2(atom y, atom x) |
|||
return 2*arctan((sqrt(power(x,2)+power(y,2)) - x)/y) |
|||
end function |
|||
atom s_lat = sin(Deg2Rad(lat)) |
|||
puts(1,"Hour, Sun Hour Angle, Dial Hour Line Angle\n") |
|||
for hour = -6 to 6 do |
|||
ha = hour * 15 - lng + lm |
|||
atom s = sin(Deg2Rad(ha)) |
|||
atom c = cos(Deg2Rad(ha)) |
|||
hla = Rad2Deg(atan2(s_lat*s,c)) |
|||
printf(1,"%3d %7.3f %7.3f\n",{hour+12,ha,hla}) |
|||
end for |
|||
{} = wait_key()</lang> |
|||
{{out}} |
|||
<pre> |
|||
Enter Latitude: -4.95 |
|||
Enter Longitude: -150.5 |
|||
Enter Legal Meridian: -150 |
|||
Hour, Sun Hour Angle, Dial Hour Line Angle |
|||
6 -89.500 84.225 |
|||
7 -74.500 17.283 |
|||
8 -59.500 8.334 |
|||
9 -44.500 4.847 |
|||
10 -29.500 2.795 |
|||
11 -14.500 1.278 |
|||
12 0.500 -0.043 |
|||
13 15.500 -1.371 |
|||
14 30.500 -2.910 |
|||
15 45.500 -5.018 |
|||
16 60.500 -8.671 |
|||
17 75.500 -18.451 |
|||
18 90.500 -95.775 |
|||
</pre> |
</pre> |
||