diff options
Diffstat (limited to 'src/calendar.h')
-rw-r--r-- | src/calendar.h | 162 |
1 files changed, 79 insertions, 83 deletions
diff --git a/src/calendar.h b/src/calendar.h index b17e0d5..73676f5 100644 --- a/src/calendar.h +++ b/src/calendar.h | |||
@@ -1,12 +1,12 @@ | |||
1 | #ifndef _CALENDAR_H_ | 1 | #ifndef _CALENDAR_H_ |
2 | #define _CALENDAR_H_ | 2 | #define _CALENDAR_H_ |
3 | 3 | ||
4 | #include <iostream> | ||
5 | #include <string> | ||
6 | #include <ctime> | 4 | #include <ctime> |
7 | #include <vector> | ||
8 | #include <fstream> | 5 | #include <fstream> |
6 | #include <iostream> | ||
9 | #include <math.h> | 7 | #include <math.h> |
8 | #include <string> | ||
9 | #include <vector> | ||
10 | using namespace std; | 10 | using namespace std; |
11 | 11 | ||
12 | extern double pi; | 12 | extern double pi; |
@@ -14,114 +14,110 @@ extern double delta; | |||
14 | extern char jieqi[25][10]; | 14 | extern char jieqi[25][10]; |
15 | 15 | ||
16 | typedef struct tm Date; | 16 | typedef struct tm Date; |
17 | struct point | 17 | struct point { |
18 | { | 18 | int year, mon, day, hour, min, sec; |
19 | int year,mon,day,hour,min,sec; | 19 | bool isShuo, isJieqi, isZhongqi; |
20 | bool isShuo,isJieqi,isZhongqi; | 20 | int JieqiIndex, MonthIndex; |
21 | int JieqiIndex,MonthIndex; | ||
22 | bool RunYue; | 21 | bool RunYue; |
23 | double time; | 22 | double time; |
24 | point* next; | 23 | point *next; |
25 | 24 | ||
26 | point(int year,int mon,int day,int hour,int min,int sec,bool isShuo,bool isJieqi,bool isZhongqi,int JieqiIndex,int MonthIndex,bool RunYue,double time) | 25 | point(int year, int mon, int day, int hour, int min, int sec, bool isShuo, |
27 | { | 26 | bool isJieqi, bool isZhongqi, int JieqiIndex, int MonthIndex, |
28 | this->year=year; | 27 | bool RunYue, double time) { |
29 | this->mon=mon; | 28 | this->year = year; |
30 | this->day=day; | 29 | this->mon = mon; |
31 | this->hour=hour; | 30 | this->day = day; |
32 | this->min=min; | 31 | this->hour = hour; |
33 | this->sec=sec; | 32 | this->min = min; |
34 | this->isShuo=isShuo; | 33 | this->sec = sec; |
35 | this->isJieqi=isJieqi; | 34 | this->isShuo = isShuo; |
36 | this->isZhongqi=isZhongqi; | 35 | this->isJieqi = isJieqi; |
37 | this->JieqiIndex=JieqiIndex; | 36 | this->isZhongqi = isZhongqi; |
38 | this->MonthIndex=MonthIndex; | 37 | this->JieqiIndex = JieqiIndex; |
39 | this->RunYue=RunYue; | 38 | this->MonthIndex = MonthIndex; |
40 | this->time=time; | 39 | this->RunYue = RunYue; |
41 | this->next=NULL; | 40 | this->time = time; |
41 | this->next = NULL; | ||
42 | } | 42 | } |
43 | }; | 43 | }; |
44 | 44 | ||
45 | class Julian | 45 | class Julian { |
46 | { | 46 | private: |
47 | private: | 47 | static double d[23][5]; |
48 | static double d[23][5]; | ||
49 | 48 | ||
50 | double dt_ext(int y,double jsd); | 49 | double dt_ext(int y, double jsd); |
51 | 50 | ||
52 | //计算力学时与世界时之差,传入年份 | 51 | //计算力学时与世界时之差,传入年份 |
53 | double delta_t(int y); | 52 | double delta_t(int y); |
54 | public: | ||
55 | // 计算儒略日 | ||
56 | double getJulianDay(time_t time); | ||
57 | 53 | ||
58 | // 计算儒略千年数 | 54 | public: |
59 | double getJulianKiloYear(time_t time); | 55 | // 计算儒略日 |
56 | double getJulianDay(time_t time); | ||
60 | 57 | ||
61 | //儒略千年数转时间戳 | 58 | // 计算儒略千年数 |
62 | time_t kiloYearToTime(double t,int year); | 59 | double getJulianKiloYear(time_t time); |
63 | }; | ||
64 | |||
65 | |||
66 | class parameter | ||
67 | { | ||
68 | private: | ||
69 | 60 | ||
70 | // 计算地球日心黄经 | 61 | //儒略千年数转时间戳 |
71 | double get_longitude(vector<double> l,double t); | 62 | time_t kiloYearToTime(double t, int year); |
63 | }; | ||
72 | 64 | ||
73 | // 计算地球日心黄纬 | 65 | class parameter { |
74 | double get_latitude(vector<double> b,double t); | 66 | private: |
67 | // 计算地球日心黄经 | ||
68 | double get_longitude(vector<double> l, double t); | ||
75 | 69 | ||
76 | double get_R(vector<double> r,double t); | 70 | // 计算地球日心黄纬 |
71 | double get_latitude(vector<double> b, double t); | ||
77 | 72 | ||
78 | // 转换FK5误差,返回弧度制 | 73 | double get_R(vector<double> r, double t); |
79 | double delta_FK5(double L,double B,double T); | ||
80 | 74 | ||
81 | //取章动 | 75 | // FK5误,回度制 |
82 | vector<double> get_angle(double T); | 76 | double delta_FK5(double L, double B, double T); |
83 | 77 | ||
84 | //章动修 | 78 | //获取章动关角 |
85 | double nutation(double T); | 79 | vector<double> get_angle(double T); |
86 | 80 | ||
87 | //行差修正,返回弧度制 | 81 | //章修正 |
88 | double aberration(double R); | 82 | double nutation(double T); |
89 | 83 | ||
90 | // 获地日数,L地球日黄经,B为球日黄纬R为日距 | 84 | //行正,返制 |
91 | vector<vector<double>> get_parameters(double t); | 85 | double aberration(double R); |
92 | 86 | ||
93 | public: | 87 | // 获取地日运行参数,L为地球日心黄经,B为地球日心黄纬,R为地日距离 |
88 | vector<vector<double>> get_parameters(double t); | ||
94 | 89 | ||
95 | double sun_longitude(double t); | 90 | public: |
91 | double sun_longitude(double t); | ||
96 | 92 | ||
97 | double moon_longitude(double t); | 93 | double moon_longitude(double t); |
98 | }; | 94 | }; |
99 | 95 | ||
100 | class List | 96 | class List { |
101 | { | 97 | private: |
102 | private: | 98 | point *head, *tail; //链表头尾指针 |
103 | point *head,*tail;//链表头尾指针 | 99 | |
100 | bool later(point *a, point *b); | ||
104 | 101 | ||
105 | bool later(point* a,point* b); | 102 | public: |
103 | vector<point *> shuori_vec; //记录各朔日的地址 | ||
104 | vector<point *> zhongqi_vec; //记录各中气的地址 | ||
106 | 105 | ||
107 | public: | 106 | List(); |
108 | vector<point*> shuori_vec; //记录各朔日的地址 | 107 | ~List(); |
109 | vector<point*> zhongqi_vec;//记录各中气的地址 | ||
110 | 108 | ||
111 | List(); | 109 | // 链表尾部插入 |
112 | ~List(); | 110 | void append(Date *date, bool isShuo, bool isJieqi, bool isZhongqi, |
111 | int JieqiIndex, double time); | ||
113 | 112 | ||
114 | // 链表尾部插入 | 113 | //对链表进行“排序” |
115 | void append(Date* date,bool isShuo,bool isJieqi,bool isZhongqi,int JieqiIndex,double time); | 114 | void lunar_sort(); |
116 | |||
117 | //对链表进行“排序” | ||
118 | void lunar_sort(); | ||
119 | 115 | ||
120 | //置闰月 | 116 | //置闰月 |
121 | void Run(); | 117 | void Run(); |
122 | 118 | ||
123 | //输出链表内容 | 119 | //输出链表内容 |
124 | void output(); | 120 | void output(); |
125 | }; | 121 | }; |
126 | 122 | ||
127 | #endif | 123 | #endif |