diff options
Diffstat (limited to 'src/calendar.cpp')
-rw-r--r-- | src/calendar.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/calendar.cpp b/src/calendar.cpp index 9ad8413..8af1851 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp | |||
@@ -53,5 +53,29 @@ int main(int argc, char *argv[]) { | |||
53 | pair<double, double> sun = p.sun_longitude(t); | 53 | pair<double, double> sun = p.sun_longitude(t); |
54 | radToDMS("Sun longitude: ", 0, 360, sun.first); | 54 | radToDMS("Sun longitude: ", 0, 360, sun.first); |
55 | radToDMS("Sun latitude: ", -90, 90, sun.second); | 55 | radToDMS("Sun latitude: ", -90, 90, sun.second); |
56 | |||
57 | double alpha, delta; // 太阳赤经赤纬 | ||
58 | double lambda = sun.first, beta = sun.second; // 太阳黄经黄纬 | ||
59 | // 黄赤交角epsilon,23°26'21.448''转换为弧度 | ||
60 | double epsilon = (23.0 + 26.0 / 60.0 + 21.448 / 3600.0) * M_PI / 180.0; | ||
61 | |||
62 | delta = | ||
63 | asin(sin(epsilon) * sin(lambda) * cos(beta) + cos(epsilon) * sin(beta)); | ||
64 | alpha = atan2( | ||
65 | (cos(epsilon) * sin(lambda) * cos(beta) - sin(epsilon) * sin(beta)), | ||
66 | (cos(epsilon) * cos(beta))); | ||
67 | radToDMS("Sun right ascension: ", 0, 360, alpha); | ||
68 | radToDMS("Sun declination: ", -90, 90, delta); | ||
69 | // 时角 | ||
70 | double H = p.getHourAngle(t, LONGITUDE, LATITUDE, alpha); | ||
71 | double A, h; //方位角和高度角 | ||
72 | h = asin(sin(LATITUDE) * sin(delta) + cos(LATITUDE) * cos(delta) * cos(H)); | ||
73 | A = atan2(-cos(delta) * sin(H), | ||
74 | cos(LATITUDE) * sin(delta) - sin(LATITUDE) * cos(delta) * cos(H)); | ||
75 | A += M_PI; | ||
76 | // 转换为角度制输出 | ||
77 | radToDMS("Hour angle: ", 0, 360, H); | ||
78 | radToDMS("Azimuth: ", 0, 360, A); | ||
79 | radToDMS("Elevation: ", 0, 90, h); | ||
56 | return 0; | 80 | return 0; |
57 | } | 81 | } |