-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgofam.go
174 lines (134 loc) · 3.42 KB
/
gofam.go
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// Copyright 2022 HE Boliang
// All rights reserved.
package gofa
// Constant value and math functions
import "math"
// Const
const (
/* Pi */
DPI = 3.141592653589793238462643
/* 2Pi */
D2PI = 6.283185307179586476925287
/* Pi/2 */
DPI2 = 1.570796326794896619231322
/* Radians to degrees */
DR2D = 57.29577951308232087679815
/* Degrees to radians */
DD2R = 1.745329251994329576923691e-2
/* Radians to arcseconds */
DR2AS = 206264.8062470963551564734
/* Arcseconds to radians */
DAS2R = 4.848136811095359935899141e-6
/* Seconds of time to radians */
DS2R = 7.272205216643039903848712e-5
/* Arcseconds in a full circle */
TURNAS = 1296000.0
/* Milliarcseconds to radians */
DMAS2R = (DAS2R / 1e3)
/* Length of tropical year B1900 (days) */
DTY = 365.242198781
/* Seconds per day. */
DAYSEC = 86400.0
/* Days per Julian year */
DJY = 365.25
/* Days per Julian century */
DJC = 36525.0
/* Days per Julian millennium */
DJM = 365250.0
/* Reference epoch (J2000.0), Julian Date */
DJ00 = 2451545.0
/* Julian Date of Modified Julian Date zero */
DJM0 = 2400000.5
/* Reference epoch (J2000.0), Modified Julian Date */
DJM00 = 51544.5
/* 1977 Jan 1.0 as MJD */
DJM77 = 43144.0
/* TT minus TAI (s) */
TTMTAI = 32.184
/* Astronomical unit (m, IAU 2012) */
DAU = 149597870.7e3
/* Speed of light (m/s) */
CMPS = 299792458.0
/* Light time for 1 au (s) */
AULT = (DAU / CMPS)
/* Speed of light (au per day) */
DC = (DAYSEC / AULT)
/* L_G = 1 - d(TT)/d(TCG) */
ELG = 6.969290134e-10
/* L_B = 1 - d(TDB)/d(TCB), and TDB (s) at TAI 1977/1/1.0 */
ELB = 1.550519768e-8
TDB0 = -6.55e-5
/* Schwarzschild radius of the Sun (au) */
/* = 2 * 1.32712440041e20 / (2.99792458e8)^2 / 1.49597870700e11 */
SRS = 1.97412574336e-8
/* Reference ellipsoids */
WGS84 = 1
GRS80 = 2
WGS72 = 3
//
DBL_EPSILON = 2.220446049250313080847263336181640625e-16
)
/* dint(A) - truncate to nearest whole number towards zero (double) */
func dint(A float64) float64 {
if A < 0.0 {
return math.Ceil(A)
} else {
return math.Floor(A)
}
}
/* dnint(A) - round to nearest whole number (double) */
func dnint(A float64) float64 {
if math.Abs(A) < 0.5 {
return 0.0
} else {
if A < 0.0 {
return math.Ceil(A - 0.5)
} else {
return math.Floor(A + 0.5)
}
}
}
/* dsign(A,B) - magnitude of A with sign of B (double) */
func dsign(A, B float64) float64 {
if B < 0.0 {
return -math.Abs(A)
} else {
return math.Abs(A)
}
}
/* max(A,B) - larger (most +ve) of two numbers (generic) */
func gmax(A, B float64) float64 {
if A > B {
return A
}
return B
}
/* min(A,B) - smaller (least +ve) of two numbers (generic) */
func gmin(A, B float64) float64 {
if A < B {
return A
}
return B
}
func abs(A int) int {
if A < 0 {
return -A
} else {
return A
}
}
//math function
func fabs(x float64) float64 { return math.Abs(x) }
func sin(x float64) float64 { return math.Sin(x) }
func cos(x float64) float64 { return math.Cos(x) }
func tan(x float64) float64 { return math.Tan(x) }
func asin(x float64) float64 { return math.Asin(x) }
func atan(x float64) float64 { return math.Atan(x) }
func atan2(x, y float64) float64 { return math.Atan2(x, y) }
func sqrt(x float64) float64 { return math.Sqrt(x) }
func fmod(x, y float64) float64 { return math.Mod(x, y) }
func pow10(n int) float64 { return math.Pow10(n) }
func pow(x, y float64) float64 { return math.Pow(x, y) }
const (
sqrt2 = math.Sqrt2
)