-
Notifications
You must be signed in to change notification settings - Fork 2
/
other_func.c
55 lines (39 loc) · 1.47 KB
/
other_func.c
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
#include <math.h>
#include "support.h"
#include "other_func.h"
static double s_stAccInfo[] =
{
0.00, 1272494.40, 2548020.60, 3830143.80, 5120226.60, 6420865.80,
7732018.80, 9055272.60, 10388958.00, 11733065.40, 13084292.40, 14441592.00,
15800560.80, 17159347.20, 18513766.20, 19862002.20, 21201005.40, 22529659.80,
23846845.20, 25152606.00, 26447687.40, 27733451.40, 29011921.20, 30285477.60
};
//已知1900年小寒时刻为1月6日2:05:00,
const double base1900_SlightColdJD = 2415025.5868055555;
double CalculateSolarTermsByExp(int year, int st)
{
if((st < 0) || (st > 24))
return 0.0;
double stJd = 365.24219878 * (year - 1900) + s_stAccInfo[st] / 86400.0;
return base1900_SlightColdJD + stJd;
}
/*
计算节气和朔日的经验公式
当天到1900年1月0日(星期日)的差称为积日,那么第y年(1900算0年)第x个节气的积日是:
F = 365.242 * y + 6.2 + 15.22 *x - 1.9 * sin(0.262 * x)
从1900年开始的第m个朔日的公式是:
M = 1.6 + 29.5306 * m + 0.4 * sin(1 - 0.45058 * m)
*/
double CalculateSolarTermsByFm(int year, int st)
{
double baseJD = CalculateJulianDay(1900, 1, 1, 0, 0, 0.0) - 1;
int y = year - 1900;
double accDay = 365.2422 * y + 6.2 + 15.22 * st - 1.0 * sin(0.262 * st);
return baseJD + accDay;
}
double CalculateNewMoonByFm(int m)
{
double baseJD = CalculateJulianDay(1900, 1, 1, 0, 0, 0.0) - 1;
double accDay = 1.6 + 29.5306 * m + 0.4 * sin(1 - 0.45058 * m);
return baseJD + accDay;
}