Jump to content

Horizontal sundial calculations: Difference between revisions

m
(J: rephrase to highlight use of atan2)
m (→‎{{header|Java}}: Using atan2)
Line 524:
 
=={{header|Java}}==
{{trans|C}} (Substitutes in atan2 for the hour line angle calculation)
{{trans|C}}
<lang java>import java.util.Scanner;
public class Sundial {
Line 549:
hra = 15.0 * h;
hra = hra - lng + ref;
hlahraRad = radToDeg(Math.atan(slat * Math.tan(degToRad(hra))));
hla = radToDeg(Math.atan2(Math.sin(hraRad)*Math.sin(degToRad(lat)), Math.cos(hraRad)));
System.out.printf("HR= %3d; \t HRA=%7.3f; \t HLA= %7.3f\n",
h, hra, hla);
Line 572 ⟶ 573:
 
Hour, sun hour angle, dial hour line angle from 6am to 6pm
HR= -6; HRA=-89.500; HLA= 84.225
HR= -5; HRA=-74.500; HLA= 17.283
HR= -4; HRA=-59.500; HLA= 8.334
HR= -3; HRA=-44.500; HLA= 4.847
HR= -2; HRA=-29.500; HLA= 2.795
HR= -1; HRA=-14.500; HLA= 1.278
HR= 0; HRA= 0.500; HLA= -0.043
HR= 1; HRA= 15.500; HLA= -1.371
HR= 2; HRA= 30.500; HLA= -2.910
HR= 3; HRA= 45.500; HLA= -5.018
HR= 4; HRA= 60.500; HLA= -8.671
HR= 5; HRA= 75.500; HLA= -18.451
HR= 6; HRA= 90.500; HLA= 84-95.225775</pre>
 
=={{header|Logo}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.