summaryrefslogtreecommitdiffstats
path: root/src/calendar.h
blob: b17e0d59190e52cf50b3463f0e64fd3a3de4582d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef _CALENDAR_H_
#define _CALENDAR_H_

#include <iostream>
#include <string>
#include <ctime>
#include <vector>
#include <fstream>
#include <math.h>
using namespace std;

extern double pi;
extern double delta;
extern char jieqi[25][10];

typedef struct tm Date;
struct point
{
    int year,mon,day,hour,min,sec;
    bool isShuo,isJieqi,isZhongqi;
    int JieqiIndex,MonthIndex;
    bool RunYue;
    double time;
    point* next;

    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)
    {
        this->year=year;
        this->mon=mon;
        this->day=day;
        this->hour=hour;
        this->min=min;
        this->sec=sec;
        this->isShuo=isShuo;
        this->isJieqi=isJieqi;
        this->isZhongqi=isZhongqi;
        this->JieqiIndex=JieqiIndex;
        this->MonthIndex=MonthIndex;
        this->RunYue=RunYue;
        this->time=time;
        this->next=NULL;
    }
};

class Julian
{
    private:
        static double d[23][5];

        double dt_ext(int y,double jsd);

        //计算力学时与世界时之差,传入年份
        double delta_t(int y);
    public:
        // 计算儒略日
        double getJulianDay(time_t time);

        // 计算儒略千年数
        double getJulianKiloYear(time_t time);

        //儒略千年数转时间戳
        time_t kiloYearToTime(double t,int year);
};


class parameter
{
    private:

        // 计算地球日心黄经
        double get_longitude(vector<double> l,double t);

        // 计算地球日心黄纬
        double get_latitude(vector<double> b,double t);

        double get_R(vector<double> r,double t);

        // 转换FK5误差,返回弧度制
        double delta_FK5(double L,double B,double T);

        //获取章动有关角
        vector<double> get_angle(double T);

        //章动修正
        double nutation(double T);

        //光行差修正,返回弧度制
        double aberration(double R);

        // 获取地日运行参数,L为地球日心黄经,B为地球日心黄纬,R为地日距离
        vector<vector<double>> get_parameters(double t);

    public:

        double sun_longitude(double t);

        double moon_longitude(double t);
};

class List
{
    private:
        point *head,*tail;//链表头尾指针

        bool later(point* a,point* b);

    public:
        vector<point*> shuori_vec; //记录各朔日的地址
        vector<point*> zhongqi_vec;//记录各中气的地址

        List();
        ~List();

        // 链表尾部插入
        void append(Date* date,bool isShuo,bool isJieqi,bool isZhongqi,int JieqiIndex,double time);
        
        //对链表进行“排序”
        void lunar_sort();

        //置闰月
        void Run();

        //输出链表内容
        void output();
};

#endif