summaryrefslogtreecommitdiffstats
path: root/src/calendar.h
blob: 248026f56a0e0e5bdba2fc66bb79d98e1eaf7ab0 (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
#ifndef _CALENDAR_H_
#define _CALENDAR_H_

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

// 哈尔滨南岗地方经纬度
#define LONGITUDE 126.533 * M_PI / 180
#define LATITUDE 45.800 * M_PI / 180

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;
    }
};

void radToDMS(const char *message, int lowerBound, int upperBound,
              double radians);

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

    double dt_ext(int y, double jsd);

  public:
    // 计算儒略日
    double getJulianDay(time_t time);

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

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

    //计算力学时与世界时之差,传入年份
    double delta_t(int y);
};

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:
    pair<double, double> sun_longitude(double t);

    double moon_longitude(double t);

    double get_epsilon(double T);

    // 计算时角,返回弧度制
    double getHourAngle(double julianKiloYear, double longitude,
                        double latitude, double alpha);
};

extern Julian julian;
extern parameter p;
#endif