Anonymous user
Horizontal sundial calculations: Difference between revisions
m
→{{header|Java}}: Using atan2
(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)
<lang java>import java.util.Scanner;
public class Sundial {
Line 549:
hra = 15.0 * h;
hra = hra - lng + ref;
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;
HR= -5;
HR= -4;
HR= -3;
HR= -2;
HR= -1;
HR= 0;
HR= 1;
HR= 2;
HR= 3;
HR= 4;
HR= 5;
HR= 6;
=={{header|Logo}}==
|