ootk 3.0.0 → 4.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/.eslintrc.json +10 -10
  2. package/CHANGELOG.md +122 -0
  3. package/README.md +27 -40
  4. package/lib/coordinate/Hill.d.ts +50 -0
  5. package/lib/coordinate/Hill.js +214 -0
  6. package/lib/coordinate/Hill.js.map +1 -0
  7. package/lib/coordinate/index.d.ts +1 -0
  8. package/lib/coordinate/index.js +2 -0
  9. package/lib/coordinate/index.js.map +1 -0
  10. package/lib/covariance/CovarianceSample.d.ts +44 -0
  11. package/lib/covariance/CovarianceSample.js +146 -0
  12. package/lib/covariance/CovarianceSample.js.map +1 -0
  13. package/lib/covariance/StateCovariance.d.ts +41 -0
  14. package/lib/covariance/StateCovariance.js +62 -0
  15. package/lib/covariance/StateCovariance.js.map +1 -0
  16. package/lib/force/AtmosphericDrag.d.ts +32 -0
  17. package/lib/force/AtmosphericDrag.js +66 -0
  18. package/lib/force/AtmosphericDrag.js.map +1 -0
  19. package/lib/force/EarthGravity.d.ts +28 -0
  20. package/lib/force/EarthGravity.js +115 -0
  21. package/lib/force/EarthGravity.js.map +1 -0
  22. package/{dist/ootk.d.ts → lib/force/Force.d.ts} +10 -10
  23. package/lib/force/Force.js +30 -0
  24. package/lib/force/Force.js.map +1 -0
  25. package/lib/force/ForceModel.d.ts +38 -0
  26. package/lib/force/ForceModel.js +71 -0
  27. package/lib/force/ForceModel.js.map +1 -0
  28. package/lib/force/Gravity.d.ts +41 -0
  29. package/lib/force/Gravity.js +48 -0
  30. package/lib/force/Gravity.js.map +1 -0
  31. package/lib/force/SolarRadiationPressure.d.ts +27 -0
  32. package/lib/force/SolarRadiationPressure.js +42 -0
  33. package/lib/force/SolarRadiationPressure.js.map +1 -0
  34. package/lib/force/ThirdBodyGravity.d.ts +27 -0
  35. package/lib/force/ThirdBodyGravity.js +56 -0
  36. package/lib/force/ThirdBodyGravity.js.map +1 -0
  37. package/lib/force/Thrust.d.ts +35 -0
  38. package/lib/force/Thrust.js +53 -0
  39. package/lib/force/Thrust.js.map +1 -0
  40. package/lib/interpolator/ChebyshevCoefficients.d.ts +54 -0
  41. package/lib/interpolator/ChebyshevCoefficients.js +90 -0
  42. package/lib/interpolator/ChebyshevCoefficients.js.map +1 -0
  43. package/lib/interpolator/ChebyshevInterpolator.d.ts +39 -0
  44. package/lib/interpolator/ChebyshevInterpolator.js +71 -0
  45. package/lib/interpolator/ChebyshevInterpolator.js.map +1 -0
  46. package/lib/interpolator/CubicSpline.d.ts +36 -0
  47. package/lib/interpolator/CubicSpline.js +64 -0
  48. package/lib/interpolator/CubicSpline.js.map +1 -0
  49. package/lib/interpolator/CubicSplineInterpolator.d.ts +37 -0
  50. package/lib/interpolator/CubicSplineInterpolator.js +78 -0
  51. package/lib/interpolator/CubicSplineInterpolator.js.map +1 -0
  52. package/lib/interpolator/FieldInterpolator.d.ts +26 -0
  53. package/lib/interpolator/FieldInterpolator.js +31 -0
  54. package/lib/interpolator/FieldInterpolator.js.map +1 -0
  55. package/lib/interpolator/Interpolator.d.ts +23 -0
  56. package/lib/interpolator/Interpolator.js +48 -0
  57. package/lib/interpolator/Interpolator.js.map +1 -0
  58. package/lib/interpolator/LagrangeInterpolator.d.ts +42 -0
  59. package/lib/interpolator/LagrangeInterpolator.js +156 -0
  60. package/lib/interpolator/LagrangeInterpolator.js.map +1 -0
  61. package/lib/interpolator/StateInterpolator.d.ts +29 -0
  62. package/lib/interpolator/StateInterpolator.js +37 -0
  63. package/lib/interpolator/StateInterpolator.js.map +1 -0
  64. package/lib/interpolator/VerletBlendInterpolator.d.ts +44 -0
  65. package/lib/interpolator/VerletBlendInterpolator.js +115 -0
  66. package/lib/interpolator/VerletBlendInterpolator.js.map +1 -0
  67. package/lib/maneuver/TwoBurnOrbitTransfer.d.ts +43 -0
  68. package/lib/maneuver/TwoBurnOrbitTransfer.js +62 -0
  69. package/lib/maneuver/TwoBurnOrbitTransfer.js.map +1 -0
  70. package/lib/maneuver/Waypoint.d.ts +66 -0
  71. package/lib/maneuver/Waypoint.js +152 -0
  72. package/lib/maneuver/Waypoint.js.map +1 -0
  73. package/lib/objects/DetailedSatellite.d.ts +94 -0
  74. package/lib/objects/DetailedSatellite.js +140 -0
  75. package/lib/objects/DetailedSatellite.js.map +1 -0
  76. package/lib/objects/DetailedSensor.d.ts +43 -0
  77. package/lib/objects/DetailedSensor.js +45 -0
  78. package/lib/objects/DetailedSensor.js.map +1 -0
  79. package/{dist/objects/space-object.d.ts → lib/objects/LandObject.d.ts} +19 -21
  80. package/lib/objects/LandObject.js +28 -0
  81. package/lib/objects/LandObject.js.map +1 -0
  82. package/lib/objects/Marker.d.ts +21 -0
  83. package/lib/objects/Marker.js +25 -0
  84. package/lib/objects/Marker.js.map +1 -0
  85. package/lib/objects/index.d.ts +5 -4
  86. package/lib/objects/index.js +5 -4
  87. package/lib/objects/index.js.map +1 -1
  88. package/lib/observation/Observation.d.ts +51 -0
  89. package/lib/observation/Observation.js +71 -0
  90. package/lib/observation/Observation.js.map +1 -0
  91. package/lib/observation/ObservationOptical.d.ts +47 -0
  92. package/lib/observation/ObservationOptical.js +101 -0
  93. package/lib/observation/ObservationOptical.js.map +1 -0
  94. package/lib/observation/ObservationRadar.d.ts +43 -0
  95. package/lib/observation/ObservationRadar.js +90 -0
  96. package/lib/observation/ObservationRadar.js.map +1 -0
  97. package/lib/observation/ObservationUtils.d.ts +21 -0
  98. package/lib/observation/ObservationUtils.js +33 -0
  99. package/lib/observation/ObservationUtils.js.map +1 -0
  100. package/lib/observation/PropagatorPairs.d.ts +31 -0
  101. package/lib/observation/PropagatorPairs.js +40 -0
  102. package/lib/observation/PropagatorPairs.js.map +1 -0
  103. package/lib/ootk.d.ts +10 -8
  104. package/lib/ootk.js +10 -8
  105. package/lib/ootk.js.map +1 -1
  106. package/lib/operations/BoxMuller.d.ts +41 -0
  107. package/lib/operations/BoxMuller.js +66 -0
  108. package/lib/operations/BoxMuller.js.map +1 -0
  109. package/lib/operations/EulerAngles.d.ts +50 -0
  110. package/lib/operations/EulerAngles.js +111 -0
  111. package/lib/operations/EulerAngles.js.map +1 -0
  112. package/lib/operations/Quaternion.d.ts +57 -0
  113. package/lib/operations/Quaternion.js +164 -0
  114. package/lib/operations/Quaternion.js.map +1 -0
  115. package/lib/operations/RandomGaussianSource.d.ts +25 -0
  116. package/lib/operations/RandomGaussianSource.js +43 -0
  117. package/lib/operations/RandomGaussianSource.js.map +1 -0
  118. package/lib/operations/index.d.ts +4 -0
  119. package/lib/operations/index.js +5 -0
  120. package/lib/operations/index.js.map +1 -0
  121. package/lib/optimize/ChebyshevCompressor.d.ts +31 -0
  122. package/lib/optimize/ChebyshevCompressor.js +80 -0
  123. package/lib/optimize/ChebyshevCompressor.js.map +1 -0
  124. package/lib/optimize/DownhillSimplex.d.ts +50 -0
  125. package/lib/optimize/DownhillSimplex.js +168 -0
  126. package/lib/optimize/DownhillSimplex.js.map +1 -0
  127. package/lib/optimize/GoldenSection.d.ts +33 -0
  128. package/lib/optimize/GoldenSection.js +49 -0
  129. package/lib/optimize/GoldenSection.js.map +1 -0
  130. package/lib/optimize/PolynomialRegression.d.ts +37 -0
  131. package/lib/optimize/PolynomialRegression.js +66 -0
  132. package/lib/optimize/PolynomialRegression.js.map +1 -0
  133. package/lib/optimize/PolynomicalRegressionResult.d.ts +28 -0
  134. package/lib/optimize/PolynomicalRegressionResult.js +32 -0
  135. package/lib/optimize/PolynomicalRegressionResult.js.map +1 -0
  136. package/lib/optimize/SimpleLinearRegression.d.ts +41 -0
  137. package/lib/optimize/SimpleLinearRegression.js +107 -0
  138. package/lib/optimize/SimpleLinearRegression.js.map +1 -0
  139. package/lib/optimize/SimplexEntry.d.ts +33 -0
  140. package/lib/optimize/SimplexEntry.js +39 -0
  141. package/lib/optimize/SimplexEntry.js.map +1 -0
  142. package/lib/orbit_determination/BatchLeastSquaresOD.d.ts +54 -0
  143. package/lib/orbit_determination/BatchLeastSquaresOD.js +118 -0
  144. package/lib/orbit_determination/BatchLeastSquaresOD.js.map +1 -0
  145. package/lib/orbit_determination/BatchLeastSquaresResult.d.ts +29 -0
  146. package/lib/orbit_determination/BatchLeastSquaresResult.js +31 -0
  147. package/lib/orbit_determination/BatchLeastSquaresResult.js.map +1 -0
  148. package/lib/orbit_determination/GibbsIOD.d.ts +33 -0
  149. package/lib/orbit_determination/GibbsIOD.js +70 -0
  150. package/lib/orbit_determination/GibbsIOD.js.map +1 -0
  151. package/lib/orbit_determination/GoodingIOD.d.ts +52 -0
  152. package/lib/orbit_determination/GoodingIOD.js +244 -0
  153. package/lib/orbit_determination/GoodingIOD.js.map +1 -0
  154. package/lib/{objects/space-object.d.ts → orbit_determination/HerrickGibbsIOD.d.ts} +17 -22
  155. package/lib/orbit_determination/HerrickGibbsIOD.js +49 -0
  156. package/lib/orbit_determination/HerrickGibbsIOD.js.map +1 -0
  157. package/lib/orbit_determination/LambertIOD.d.ts +46 -0
  158. package/lib/orbit_determination/LambertIOD.js +199 -0
  159. package/lib/orbit_determination/LambertIOD.js.map +1 -0
  160. package/lib/orbit_determination/ModifiedGoodingIOD.d.ts +41 -0
  161. package/lib/orbit_determination/ModifiedGoodingIOD.js +82 -0
  162. package/lib/orbit_determination/ModifiedGoodingIOD.js.map +1 -0
  163. package/lib/propagator/DormandPrince54Propagator.d.ts +29 -0
  164. package/lib/propagator/DormandPrince54Propagator.js +68 -0
  165. package/lib/propagator/DormandPrince54Propagator.js.map +1 -0
  166. package/lib/propagator/KeplerPropagator.d.ts +36 -0
  167. package/lib/propagator/KeplerPropagator.js +81 -0
  168. package/lib/propagator/KeplerPropagator.js.map +1 -0
  169. package/lib/propagator/Propagator.d.ts +35 -0
  170. package/lib/propagator/Propagator.js +163 -0
  171. package/lib/propagator/Propagator.js.map +1 -0
  172. package/lib/propagator/RkCheckpoint.d.ts +23 -0
  173. package/lib/propagator/RkCheckpoint.js +26 -0
  174. package/lib/propagator/RkCheckpoint.js.map +1 -0
  175. package/lib/propagator/RkResult.d.ts +24 -0
  176. package/lib/propagator/RkResult.js +28 -0
  177. package/lib/propagator/RkResult.js.map +1 -0
  178. package/lib/propagator/RungeKutta4Propagator.d.ts +46 -0
  179. package/lib/propagator/RungeKutta4Propagator.js +132 -0
  180. package/lib/propagator/RungeKutta4Propagator.js.map +1 -0
  181. package/lib/propagator/RungeKutta89Propagator.d.ts +29 -0
  182. package/lib/propagator/RungeKutta89Propagator.js +130 -0
  183. package/lib/propagator/RungeKutta89Propagator.js.map +1 -0
  184. package/lib/propagator/RungeKuttaAdaptive.d.ts +52 -0
  185. package/lib/propagator/RungeKuttaAdaptive.js +152 -0
  186. package/lib/propagator/RungeKuttaAdaptive.js.map +1 -0
  187. package/lib/propagator/Sgp4Propagator.d.ts +35 -0
  188. package/lib/propagator/Sgp4Propagator.js +55 -0
  189. package/lib/propagator/Sgp4Propagator.js.map +1 -0
  190. package/lib/smoothing/ExponentialSmoothing.d.ts +24 -0
  191. package/lib/smoothing/ExponentialSmoothing.js +82 -0
  192. package/lib/smoothing/ExponentialSmoothing.js.map +1 -0
  193. package/lib/types/types.d.ts +65 -584
  194. package/lib/types/types.js +21 -33
  195. package/lib/types/types.js.map +1 -1
  196. package/package.json +16 -14
  197. package/.prettierrc +0 -17
  198. package/babel.config.js +0 -16
  199. package/codecov.yml +0 -21
  200. package/dist/objects/base-object.d.ts +0 -40
  201. package/dist/objects/detailed-sat.d.ts +0 -66
  202. package/dist/objects/index.d.ts +0 -4
  203. package/dist/objects/sat.d.ts +0 -92
  204. package/dist/objects/sensor.d.ts +0 -93
  205. package/dist/objects/star.d.ts +0 -46
  206. package/dist/ootk.js +0 -2
  207. package/dist/ootk.js.LICENSE.txt +0 -77
  208. package/dist/sgp4/sgp4.d.ts +0 -82
  209. package/dist/tle/tle-format-data.d.ts +0 -6
  210. package/dist/tle/tle.d.ts +0 -375
  211. package/dist/transforms/transforms.d.ts +0 -94
  212. package/dist/types/types.d.ts +0 -605
  213. package/dist/utils/constants.d.ts +0 -34
  214. package/dist/utils/moon-math.d.ts +0 -113
  215. package/dist/utils/sun-math.d.ts +0 -230
  216. package/dist/utils/utils.d.ts +0 -39
  217. package/lib/objects/base-object.d.ts +0 -40
  218. package/lib/objects/base-object.js +0 -79
  219. package/lib/objects/base-object.js.map +0 -1
  220. package/lib/objects/detailed-sat.d.ts +0 -66
  221. package/lib/objects/detailed-sat.js +0 -149
  222. package/lib/objects/detailed-sat.js.map +0 -1
  223. package/lib/objects/sat.d.ts +0 -92
  224. package/lib/objects/sat.js +0 -188
  225. package/lib/objects/sat.js.map +0 -1
  226. package/lib/objects/sensor.d.ts +0 -93
  227. package/lib/objects/sensor.js +0 -273
  228. package/lib/objects/sensor.js.map +0 -1
  229. package/lib/objects/space-object.js +0 -60
  230. package/lib/objects/space-object.js.map +0 -1
  231. package/lib/objects/star.d.ts +0 -46
  232. package/lib/objects/star.js +0 -91
  233. package/lib/objects/star.js.map +0 -1
  234. package/lib/sgp4/sgp4.d.ts +0 -82
  235. package/lib/sgp4/sgp4.js +0 -3262
  236. package/lib/sgp4/sgp4.js.map +0 -1
  237. package/lib/tle/tle-format-data.d.ts +0 -6
  238. package/lib/tle/tle-format-data.js +0 -10
  239. package/lib/tle/tle-format-data.js.map +0 -1
  240. package/lib/tle/tle.d.ts +0 -375
  241. package/lib/tle/tle.js +0 -611
  242. package/lib/tle/tle.js.map +0 -1
  243. package/lib/transforms/transforms.d.ts +0 -94
  244. package/lib/transforms/transforms.js +0 -308
  245. package/lib/transforms/transforms.js.map +0 -1
  246. package/lib/utils/constants.d.ts +0 -34
  247. package/lib/utils/constants.js +0 -35
  248. package/lib/utils/constants.js.map +0 -1
  249. package/lib/utils/moon-math.d.ts +0 -113
  250. package/lib/utils/moon-math.js +0 -387
  251. package/lib/utils/moon-math.js.map +0 -1
  252. package/lib/utils/sun-math.d.ts +0 -230
  253. package/lib/utils/sun-math.js +0 -422
  254. package/lib/utils/sun-math.js.map +0 -1
  255. package/lib/utils/utils.d.ts +0 -39
  256. package/lib/utils/utils.js +0 -102
  257. package/lib/utils/utils.js.map +0 -1
  258. package/sandbox.html +0 -8
  259. package/tsconfig.base.json +0 -31
  260. package/tsconfig.build.json +0 -14
  261. /package/{LICENSE.MD → LICENSE.md} +0 -0
package/lib/sgp4/sgp4.js DELETED
@@ -1,3262 +0,0 @@
1
- /**
2
- * @author Theodore Kruczek.
3
- * @description Orbital Object ToolKit (OOTK) is a collection of tools for working
4
- * with satellites and other orbital objects.
5
- *
6
- * @file The Sgp4 module contains a TypeScript port of the 2020 version of
7
- * sgp4unit.cpp from "Fundamentals of Astrodynamics and Applications" by David
8
- * Vallado. All of the original comments and notes are inserted in the code below
9
- * in order provide context to the functions and clarify any adjustments made for
10
- * TypeScript/JavaScript compatibility.
11
- *
12
- * @license AGPL-3.0-or-later
13
- * @Copyright (c) 2020-2023 Theodore Kruczek
14
- *
15
- * Orbital Object ToolKit is free software: you can redistribute it and/or modify it under the
16
- * terms of the GNU Affero General Public License as published by the Free Software
17
- * Foundation, either version 3 of the License, or (at your option) any later version.
18
- *
19
- * Orbital Object ToolKit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
20
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
- * See the GNU Affero General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU Affero General Public License along with
24
- * Orbital Object ToolKit. If not, see <http://www.gnu.org/licenses/>.
25
- */
26
- import { DEG2RAD, PI, TAU, temp4, x2o3 } from '../utils/constants';
27
- /*
28
- * ----------------------------------------------------------------
29
- *
30
- * sgp4unit.cpp
31
- *
32
- * this file contains the sgp4 procedures for analytical propagation
33
- * of a satellite. the code was originally released in the 1980 and 1986
34
- * spacetrack papers. a detailed discussion of the theory and history
35
- * may be found in the 2006 aiaa paper by vallado, crawford, hujsak,
36
- * and kelso.
37
- *
38
- * companion code for
39
- * fundamentals of astrodynamics and applications
40
- * 2013
41
- * by david vallado
42
- *
43
- * (w) 719-573-2600, email dvallado@agi.com, davallado@gmail.com
44
- *
45
- * current :
46
- * 12 mar 20 david vallado
47
- * chg satnum to string for alpha 5 or 9-digit
48
- * changes :
49
- * 7 dec 15 david vallado
50
- * fix jd, jdfrac
51
- * 3 nov 14 david vallado
52
- * update to msvs2013 c++
53
- * 30 aug 10 david vallado
54
- * delete unused variables in initl
55
- * replace pow integer 2, 3 with multiplies for speed
56
- * 3 nov 08 david vallado
57
- * put returns in for error codes
58
- * 29 sep 08 david vallado
59
- * fix atime for faster operation in dspace
60
- * add operationmode for afspc (a) or improved (i)
61
- * performance mode
62
- * 16 jun 08 david vallado
63
- * update small eccentricity check
64
- * 16 nov 07 david vallado
65
- * misc fixes for better compliance
66
- * 20 apr 07 david vallado
67
- * misc fixes for constants
68
- * 11 aug 06 david vallado
69
- * chg lyddane choice back to strn3, constants, misc doc
70
- * 15 dec 05 david vallado
71
- * misc fixes
72
- * 26 jul 05 david vallado
73
- * fixes for paper
74
- * note that each fix is preceded by a
75
- * comment with "sgp4fix" and an explanation of
76
- * what was changed
77
- * 10 aug 04 david vallado
78
- * 2nd printing baseline working
79
- * 14 may 01 david vallado
80
- * 2nd edition baseline
81
- * 80 norad
82
- * original baseline
83
- * ----------------------------------------------------------------
84
- */
85
- var Sgp4 = /** @class */ (function () {
86
- function Sgp4() {
87
- }
88
- // #region Public Static Methods (15)
89
- // Dot
90
- /*
91
- * -----------------------------------------------------------------------------
92
- *
93
- * procedure angle_SGP4
94
- *
95
- * this procedure calculates the angle between two vectors. the output is
96
- * set to 999999.1 to indicate an undefined value. be sure to check for
97
- * this at the output phase.
98
- *
99
- * author : david vallado 719-573-2600 1 mar 2001
100
- *
101
- * inputs description range / units
102
- * vec1 - vector number 1
103
- * vec2 - vector number 2
104
- *
105
- * outputs :
106
- * theta - angle between the two vectors -pi to pi
107
- *
108
- * locals :
109
- * temp - temporary real variable
110
- *
111
- * coupling :
112
- * dot dot product of two vectors
113
- * ---------------------------------------------------------------------------
114
- */
115
- Sgp4.angle = function (vec1, vec2) {
116
- var small = 0.00000001;
117
- var unknown = 999999.1; /** Ootk -- original 'undefined' is protected in JS */
118
- var magv1 = Sgp4.mag(vec1);
119
- var magv2 = Sgp4.mag(vec2);
120
- if (magv1 * magv2 > small * small) {
121
- var temp = Sgp4.dot(vec1, vec2) / (magv1 * magv2);
122
- if (Math.abs(temp) > 1.0) {
123
- temp = Number(Sgp4.sgn(temp));
124
- }
125
- return Math.acos(temp);
126
- }
127
- return unknown;
128
- };
129
- // Angle
130
- /*
131
- * -----------------------------------------------------------------------------
132
- *
133
- * function asinh_SGP4
134
- *
135
- * this function evaluates the inverse hyperbolic sine function.
136
- *
137
- * author : david vallado 719-573-2600 1 mar 2001
138
- *
139
- * inputs description range / units
140
- * xval - angle value any real
141
- *
142
- * outputs :
143
- * arcsinh - result any real
144
- *
145
- * locals :
146
- * none.
147
- *
148
- * coupling :
149
- * none.
150
- * ---------------------------------------------------------------------------
151
- */
152
- Sgp4.asinh = function (xval) {
153
- return Math.log(xval + Math.sqrt(xval * xval + 1.0));
154
- };
155
- // Getgravconst
156
- /*
157
- * -----------------------------------------------------------------------------
158
- *
159
- * function twoline2rv
160
- *
161
- * this function converts the two line element set character string data to
162
- * variables and initializes the sgp4 variables. several intermediate varaibles
163
- * and quantities are determined. note that the result is a structure so multiple
164
- * satellites can be processed simultaneously without having to reinitialize. the
165
- * verification mode is an important option that permits quick checks of any
166
- * changes to the underlying technical theory. this option works using a
167
- * modified tle file in which the start, stop, and delta time values are
168
- * included at the end of the second line of data. this only works with the
169
- * verification mode. the catalog mode simply propagates from -1440 to 1440 min
170
- * from epoch and is useful when performing entire catalog runs.
171
- *
172
- * author : david vallado 719-573-2600 1 mar 2001
173
- *
174
- * inputs :
175
- * longstr1 - first line of the tle
176
- * longstr2 - second line of the tle
177
- * typerun - type of run verification 'v', catalog 'c',
178
- * manual 'm'
179
- * typeinput - type of manual input mfe 'm', epoch 'e', dayofyr 'd'
180
- * opsmode - mode of operation afspc or improved 'a', 'i'
181
- * whichconst - which set of constants to use 72, 84
182
- *
183
- * outputs :
184
- * satrec - structure containing all the sgp4 satellite information
185
- *
186
- * coupling :
187
- * getgravconst-
188
- * days2mdhms - conversion of days to month, day, hour, minute, second
189
- * jday - convert day month year hour minute second into julian date
190
- * sgp4init - initialize the sgp4 variables
191
- *
192
- * references :
193
- * norad spacetrack report #3
194
- * vallado, crawford, hujsak, kelso 2006
195
- * ---------------------------------------------------------------------------
196
- */
197
- Sgp4.createSatrec = function (tleLine1, tleLine2, whichconst, opsmode) {
198
- if (whichconst === void 0) { whichconst = 'wgs72'; }
199
- if (opsmode === void 0) { opsmode = 'i'; }
200
- var year = 0;
201
- var satrec = {
202
- a: null,
203
- am: null,
204
- alta: null,
205
- altp: null,
206
- argpdot: null,
207
- argpo: null,
208
- aycof: null,
209
- bstar: null,
210
- cc1: null,
211
- cc4: null,
212
- cc5: null,
213
- con41: null,
214
- d2: null,
215
- d3: null,
216
- d4: null,
217
- d5232: null,
218
- d5421: null,
219
- d5433: null,
220
- dedt: null,
221
- delmo: null,
222
- del1: null,
223
- ecco: null,
224
- em: null,
225
- epochdays: null,
226
- epochyr: null,
227
- error: null,
228
- eta: null,
229
- gsto: null,
230
- im: null,
231
- inclo: null,
232
- init: null,
233
- isimp: null,
234
- jdsatepoch: null,
235
- mdot: null,
236
- method: null,
237
- mo: null,
238
- mm: null,
239
- nddot: null,
240
- ndot: null,
241
- no: null,
242
- nodecf: null,
243
- nodedot: null,
244
- nodeo: null,
245
- om: null,
246
- Om: null,
247
- omgcof: null,
248
- operationmode: null,
249
- satnum: null,
250
- sinmao: null,
251
- t: null,
252
- t2cof: null,
253
- t3cof: null,
254
- t4cof: null,
255
- t5cof: null,
256
- x1mth2: null,
257
- x7thm1: null,
258
- xlcof: null,
259
- xmcof: null,
260
- xfact: null,
261
- xlamo: null,
262
- xli: null,
263
- xgh4: null,
264
- xgh3: null,
265
- xh2: null,
266
- xi2: null,
267
- xi3: null,
268
- xl2: null,
269
- xl3: null,
270
- xl4: null,
271
- zmol: null,
272
- zmos: null,
273
- dmdt: null,
274
- dnodt: null,
275
- domdt: null,
276
- e3: null,
277
- ee2: null,
278
- peo: null,
279
- pgho: null,
280
- pho: null,
281
- PInco: null,
282
- plo: null,
283
- se2: null,
284
- se3: null,
285
- sgh2: null,
286
- sgh3: null,
287
- sgh4: null,
288
- sh2: null,
289
- sh3: null,
290
- si2: null,
291
- si3: null,
292
- sl2: null,
293
- sl3: null,
294
- sl4: null,
295
- xgh2: null,
296
- xh3: null,
297
- tumin: null,
298
- radiusearthkm: null,
299
- irez: null,
300
- d3210: null,
301
- d3222: null,
302
- d4410: null,
303
- d4422: null,
304
- d5220: null,
305
- del2: null,
306
- del3: null,
307
- didt: null,
308
- atime: null,
309
- j2: null,
310
- j3: null,
311
- j4: null,
312
- mus: null,
313
- xke: null,
314
- j3oj2: null,
315
- xni: null,
316
- d2201: null,
317
- d2211: null,
318
- nm: null,
319
- };
320
- /*
321
- * Sgp4fix no longer needed
322
- * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
323
- */
324
- var xpdotp = 1440.0 / (2.0 * PI); // 229.1831180523293;
325
- satrec.error = 0;
326
- satrec.satnum = tleLine1.substring(2, 7);
327
- satrec.epochyr = parseInt(tleLine1.substring(18, 20));
328
- satrec.epochdays = parseFloat(tleLine1.substring(20, 32));
329
- satrec.ndot = parseFloat(tleLine1.substring(33, 43));
330
- satrec.nddot = parseFloat("".concat(tleLine1.substring(44, 45), ".").concat(tleLine1.substring(45, 50), "E").concat(tleLine1.substring(50, 52)));
331
- satrec.bstar = parseFloat("".concat(tleLine1.substring(53, 54), ".").concat(tleLine1.substring(54, 59), "E").concat(tleLine1.substring(59, 61)));
332
- // Satrec.satnum = tleLine2.substring(2, 7);
333
- satrec.inclo = parseFloat(tleLine2.substring(8, 16));
334
- satrec.nodeo = parseFloat(tleLine2.substring(17, 25));
335
- satrec.ecco = parseFloat(".".concat(tleLine2.substring(26, 33)));
336
- satrec.argpo = parseFloat(tleLine2.substring(34, 42));
337
- satrec.mo = parseFloat(tleLine2.substring(43, 51));
338
- satrec.no = parseFloat(tleLine2.substring(52, 63));
339
- // ---- find no, ndot, nddot ----
340
- satrec.no /= xpdotp; // Rad/min
341
- /** Ootk -- nexp and ibexp are calculated above using template literals */
342
- /*
343
- * Satrec.nddot = satrec.nddot * Math.pow(10.0, nexp);
344
- * satrec.bstar = satrec.bstar * Math.pow(10.0, ibexp);
345
- */
346
- /*
347
- * ---- convert to sgp4 units ----
348
- * satrec.a = (satrec.no * tumin) ** (-2.0 / 3.0);
349
- */
350
- /** Ootk -- Not sure why the following two lines are added. 1st and 2nd derivatives aren't even used anymore */
351
- /*
352
- * Satrec.ndot /= xpdotp * 1440.0; // ? * minperday
353
- * satrec.nddot /= xpdotp * 1440.0 * 1440;
354
- */
355
- // ---- find standard orbital elements ----
356
- satrec.inclo *= DEG2RAD;
357
- satrec.nodeo *= DEG2RAD;
358
- satrec.argpo *= DEG2RAD;
359
- satrec.mo *= DEG2RAD;
360
- /*
361
- * Sgp4fix not needed here
362
- * satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
363
- * satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
364
- */
365
- /*
366
- * ----------------------------------------------------------------
367
- * find sgp4epoch time of element set
368
- * remember that sgp4 uses units of days from 0 jan 1950 (sgp4epoch)
369
- * and minutes from the epoch (time)
370
- * ----------------------------------------------------------------
371
- */
372
- /*
373
- * ---------------- temp fix for years from 1957-2056 -------------------
374
- * --------- correct fix will occur when year is 4-digit in tle ---------
375
- */
376
- if (satrec.epochyr < 57) {
377
- year = satrec.epochyr + 2000;
378
- }
379
- else {
380
- year = satrec.epochyr + 1900;
381
- }
382
- var _a = Sgp4.days2mdhms(year, satrec.epochdays), mon = _a.mon, day = _a.day, hr = _a.hr, min = _a.min, sec = _a.sec;
383
- var jdayRes = Sgp4.jday(year, mon, day, hr, min, sec);
384
- satrec.jdsatepoch = jdayRes.jd + jdayRes.jdFrac;
385
- // ---------------- initialize the orbit at sgp4epoch -------------------
386
- Sgp4.sgp4init_(satrec, {
387
- whichconst: whichconst,
388
- opsmode: opsmode,
389
- satn: satrec.satnum,
390
- epoch: satrec.jdsatepoch - 2433281.5,
391
- xbstar: satrec.bstar,
392
- xecco: satrec.ecco,
393
- xargpo: satrec.argpo,
394
- xinclo: satrec.inclo,
395
- xndot: satrec.ndot,
396
- xnddot: satrec.nddot,
397
- xmo: satrec.mo,
398
- xno: satrec.no,
399
- xnodeo: satrec.nodeo,
400
- });
401
- return satrec;
402
- };
403
- // Mag
404
- /*
405
- * -----------------------------------------------------------------------------
406
- *
407
- * procedure cross_SGP4
408
- *
409
- * this procedure crosses two vectors.
410
- *
411
- * author : david vallado 719-573-2600 1 mar 2001
412
- *
413
- * inputs description range / units
414
- * vec1 - vector number 1
415
- * vec2 - vector number 2
416
- *
417
- * outputs :
418
- * outvec - vector result of a x b
419
- *
420
- * locals :
421
- * none.
422
- *
423
- * coupling :
424
- * mag magnitude of a vector
425
- * ----------------------------------------------------------------------------
426
- */
427
- Sgp4.cross = function (vec1, vec2) {
428
- var outvec = [0, 0, 0];
429
- outvec[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
430
- outvec[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
431
- outvec[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];
432
- return outvec;
433
- };
434
- // Jday
435
- /*
436
- * -----------------------------------------------------------------------------
437
- *
438
- * procedure days2mdhms
439
- *
440
- * this procedure converts the day of the year, days, to the equivalent month
441
- * day, hour, minute and second.
442
- *
443
- * algorithm : set up array for the number of days per month
444
- * find leap year - use 1900 because 2000 is a leap year
445
- * loop through a temp value while the value is < the days
446
- * perform int conversions to the correct day and month
447
- * convert remainder into h m s using type conversions
448
- *
449
- * author : david vallado 719-573-2600 1 mar 2001
450
- *
451
- * inputs description range / units
452
- * year - year 1900 .. 2100
453
- * days - julian day of the year 0.0 .. 366.0
454
- *
455
- * outputs :
456
- * mon - month 1 .. 12
457
- * day - day 1 .. 28,29,30,31
458
- * hr - hour 0 .. 23
459
- * min - minute 0 .. 59
460
- * sec - second 0.0 .. 59.999
461
- *
462
- * locals :
463
- * dayofyr - day of year
464
- * temp - temporary extended values
465
- * inttemp - temporary int value
466
- * i - index
467
- * lmonth[13] - int array containing the number of days per month
468
- *
469
- * coupling :
470
- * none.
471
- * ---------------------------------------------------------------------------
472
- */
473
- Sgp4.days2mdhms = function (year, days) {
474
- var lmonth = [31, year % 4 === 0 ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
475
- var dayofyr = Math.floor(days);
476
- // ----------------- find month and day of month ----------------
477
- /** Ootk -- Incorporated in the above declaration */
478
- /*
479
- * If ((year % 4) == 0)
480
- * lmonth[2] = 29;
481
- */
482
- var i = 1;
483
- var inttemp = 0;
484
- while (dayofyr > inttemp + lmonth[i - 1] && i < 12) {
485
- inttemp += lmonth[i - 1];
486
- i += 1;
487
- }
488
- var mon = i;
489
- var day = dayofyr - inttemp;
490
- // ----------------- find hours minutes and seconds -------------
491
- var temp = (days - dayofyr) * 24.0;
492
- var hr = Math.floor(temp);
493
- temp = (temp - hr) * 60.0;
494
- var min = Math.floor(temp);
495
- var sec = (temp - min) * 60.0;
496
- return {
497
- mon: mon,
498
- day: day,
499
- hr: hr,
500
- min: min,
501
- sec: sec,
502
- };
503
- };
504
- // End cross
505
- /*
506
- * -----------------------------------------------------------------------------
507
- *
508
- * function dot_SGP4
509
- *
510
- * this function finds the dot product of two vectors.
511
- *
512
- * author : david vallado 719-573-2600 1 mar 2001
513
- *
514
- * inputs description range / units
515
- * vec1 - vector number 1
516
- * vec2 - vector number 2
517
- *
518
- * outputs :
519
- * dot - result
520
- *
521
- * locals :
522
- * none.
523
- *
524
- * coupling :
525
- * none.
526
- * ---------------------------------------------------------------------------
527
- */
528
- Sgp4.dot = function (x, y) {
529
- return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
530
- };
531
- // Twoline2rv
532
- /*
533
- * -----------------------------------------------------------------------------
534
- *
535
- * function gstime
536
- *
537
- * this function finds the greenwich sidereal time.
538
- *
539
- * author : david vallado 719-573-2600 1 mar 2001
540
- *
541
- * inputs description range / units
542
- * jdut1 - julian date in ut1 days from 4713 bc
543
- *
544
- * outputs :
545
- * gstime - greenwich sidereal time 0 to 2PI rad
546
- *
547
- * locals :
548
- * temp - temporary variable for doubles rad
549
- * tut1 - julian centuries from the
550
- * jan 1, 2000 12 h epoch (ut1)
551
- *
552
- * coupling :
553
- * none
554
- *
555
- * references :
556
- * vallado 2004, 191, eq 3-45
557
- * ---------------------------------------------------------------------------
558
- */
559
- Sgp4.gstime = function (jdut1) {
560
- var tut1 = (jdut1 - 2451545.0) / 36525.0;
561
- var temp = -6.2e-6 * tut1 * tut1 * tut1 + 0.093104 * tut1 * tut1 + (876600.0 * 3600 + 8640184.812866) * tut1 + 67310.54841; // Sec
562
- temp = ((temp * DEG2RAD) / 240.0) % TAU; // 360/86400 = 1/240, to deg, to rad
563
- // ------------------------ check quadrants ---------------------
564
- if (temp < 0.0) {
565
- temp += TAU;
566
- }
567
- return temp;
568
- };
569
- // Days2mdhms
570
- /*
571
- * -----------------------------------------------------------------------------
572
- *
573
- * procedure invjday
574
- *
575
- * this procedure finds the year, month, day, hour, minute and second
576
- * given the julian date. tu can be ut1, tdt, tdb, etc.
577
- *
578
- * algorithm : set up starting values
579
- * find leap year - use 1900 because 2000 is a leap year
580
- * find the elapsed days through the year in a loop
581
- * call routine to find each individual value
582
- *
583
- * author : david vallado 719-573-2600 1 mar 2001
584
- *
585
- * inputs description range / units
586
- * jd - julian date days from 4713 bc
587
- * jdfrac - julian date fraction into day days from 4713 bc
588
- *
589
- * outputs :
590
- * year - year 1900 .. 2100
591
- * mon - month 1 .. 12
592
- * day - day 1 .. 28,29,30,31
593
- * hr - hour 0 .. 23
594
- * min - minute 0 .. 59
595
- * sec - second 0.0 .. 59.999
596
- *
597
- * locals :
598
- * days - day of year plus fractional
599
- * portion of a day days
600
- * tu - julian centuries from 0 h
601
- * jan 0, 1900
602
- * temp - temporary double values
603
- * leapyrs - number of leap years from 1900
604
- *
605
- * coupling :
606
- * days2mdhms - finds month, day, hour, minute and second given days and year
607
- *
608
- * references :
609
- * vallado 2013, 203, alg 22, ex 3-13
610
- * ---------------------------------------------------------------------------
611
- */
612
- Sgp4.invjday = function (jd, jdfrac) {
613
- var leapyrs;
614
- var days;
615
- // Check jdfrac for multiple days
616
- if (Math.abs(jdfrac) >= 1.0) {
617
- jd += Math.floor(jdfrac);
618
- jdfrac -= Math.floor(jdfrac);
619
- }
620
- // Check for fraction of a day included in the jd
621
- var dt = jd - Math.floor(jd) - 0.5;
622
- if (Math.abs(dt) > 0.00000001) {
623
- jd -= dt;
624
- jdfrac += dt;
625
- }
626
- /* --------------- find year and days of the year --------------- */
627
- var temp = jd - 2415019.5;
628
- var tu = temp / 365.25;
629
- var year = 1900 + Math.floor(tu);
630
- leapyrs = Math.floor((year - 1901) * 0.25);
631
- days = Math.floor(temp - ((year - 1900) * 365.0 + leapyrs));
632
- /* ------------ check for case of beginning of a year ----------- */
633
- if (days + jdfrac < 1.0) {
634
- year -= 1;
635
- leapyrs = Math.floor((year - 1901) * 0.25);
636
- days = Math.floor(temp - ((year - 1900) * 365.0 + leapyrs));
637
- }
638
- /* ----------------- find remaining data ------------------------- */
639
- var _a = Sgp4.days2mdhms(year, days + jdfrac), mon = _a.mon, day = _a.day, hr = _a.hr, min = _a.min, sec = _a.sec;
640
- return {
641
- year: year,
642
- mon: mon,
643
- day: day,
644
- hr: hr,
645
- min: min,
646
- sec: sec,
647
- };
648
- };
649
- // Rv2coe
650
- /*
651
- * -----------------------------------------------------------------------------
652
- *
653
- * procedure jday
654
- *
655
- * this procedure finds the julian date given the year, month, day, and time.
656
- * the julian date is defined by each elapsed day since noon, jan 1, 4713 bc.
657
- *
658
- * algorithm : calculate the answer in one step for efficiency
659
- *
660
- * author : david vallado 719-573-2600 1 mar 2001
661
- *
662
- * inputs description range / units
663
- * year - year 1900 .. 2100
664
- * mon - month 1 .. 12
665
- * day - day 1 .. 28,29,30,31
666
- * hr - universal time hour 0 .. 23
667
- * min - universal time min 0 .. 59
668
- * sec - universal time sec 0.0 .. 59.999
669
- *
670
- * outputs :
671
- * jd - julian date days from 4713 bc
672
- * jdfrac - julian date fraction into day days from 4713 bc
673
- *
674
- * locals :
675
- * none.
676
- *
677
- * coupling :
678
- * none.
679
- *
680
- * references :
681
- * vallado 2013, 183, alg 14, ex 3-4
682
- *
683
- * ---------------------------------------------------------------------------
684
- */
685
- Sgp4.jday = function (year, mon, day, hr, min, sec, ms) {
686
- if (mon === void 0) { mon = 0; }
687
- if (day === void 0) { day = 0; }
688
- if (hr === void 0) { hr = 0; }
689
- if (min === void 0) { min = 0; }
690
- if (sec === void 0) { sec = 0; }
691
- if (ms === void 0) { ms = 0; }
692
- if (year instanceof Date) {
693
- mon = year.getUTCMonth() + 1;
694
- day = year.getUTCDate();
695
- hr = year.getUTCHours();
696
- min = year.getUTCMinutes();
697
- sec = year.getUTCSeconds();
698
- ms = year.getUTCMilliseconds();
699
- year = year.getUTCFullYear();
700
- }
701
- var jd = 367.0 * year -
702
- Math.floor(7 * (year + Math.floor((mon + 9) / 12.0)) * 0.25) +
703
- Math.floor((275 * mon) / 9.0) +
704
- day +
705
- 1721013.5; // Use - 678987.0 to go to mjd directly
706
- var jdFrac = (ms / 1000 + sec + min * 60.0 + hr * 3600.0) / 86400.0;
707
- // Check that the day and fractional day are correct
708
- if (Math.abs(jdFrac) > 1.0) {
709
- var dtt = Math.floor(jdFrac);
710
- jd += dtt;
711
- jdFrac -= dtt;
712
- }
713
- // - 0.5*sgn(100.0*year + mon - 190002.5) + 0.5;
714
- return { jd: jd, jdFrac: jdFrac };
715
- };
716
- // Sgn
717
- /*
718
- * -----------------------------------------------------------------------------
719
- *
720
- * function mag
721
- *
722
- * this procedure finds the magnitude of a vector.
723
- *
724
- * author : david vallado 719-573-2600 1 mar 2001
725
- *
726
- * inputs description range / units
727
- * vec - vector
728
- *
729
- * outputs :
730
- * mag - answer
731
- *
732
- * locals :
733
- * none.
734
- *
735
- * coupling :
736
- * none.
737
- * ---------------------------------------------------------------------------
738
- */
739
- Sgp4.mag = function (x) {
740
- return Math.sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]);
741
- };
742
- // Asinh
743
- /*
744
- * -----------------------------------------------------------------------------
745
- *
746
- * function newtonnu_SGP4
747
- *
748
- * this function solves keplers equation when the true anomaly is known.
749
- * the mean and eccentric, parabolic, or hyperbolic anomaly is also found.
750
- * the parabolic limit at 168ø is arbitrary. the hyperbolic anomaly is also
751
- * limited. the hyperbolic sine is used because it's not double valued.
752
- *
753
- * author : david vallado 719-573-2600 27 may 2002
754
- *
755
- * revisions
756
- * vallado - fix small 24 sep 2002
757
- *
758
- * inputs description range / units
759
- * ecc - eccentricity 0.0 to
760
- * nu - true anomaly -2pi to 2pi rad
761
- *
762
- * outputs :
763
- * e0 - eccentric anomaly 0.0 to 2pi rad 153.02 ø
764
- * m - mean anomaly 0.0 to 2pi rad 151.7425 ø
765
- *
766
- * locals :
767
- * e1 - eccentric anomaly, next value rad
768
- * sine - sine of e
769
- * cose - cosine of e
770
- * ktr - index
771
- *
772
- * coupling :
773
- * asinh - arc hyperbolic sine
774
- *
775
- * references :
776
- * vallado 2013, 77, alg 5
777
- * ---------------------------------------------------------------------------
778
- */
779
- Sgp4.newtonnu = function (ecc, nu) {
780
- // --------------------- implementation ---------------------
781
- var e0 = 999999.9;
782
- var m = 999999.9;
783
- var small = 0.00000001;
784
- if (Math.abs(ecc) < small) {
785
- // --------------------------- circular ------------------------
786
- m = nu;
787
- e0 = nu;
788
- }
789
- else if (ecc < 1.0 - small) {
790
- // ---------------------- elliptical -----------------------
791
- var sine = (Math.sqrt(1.0 - ecc * ecc) * Math.sin(nu)) / (1.0 + ecc * Math.cos(nu));
792
- var cose = (ecc + Math.cos(nu)) / (1.0 + ecc * Math.cos(nu));
793
- e0 = Math.atan2(sine, cose);
794
- m = e0 - ecc * Math.sin(e0);
795
- }
796
- else if (ecc > 1.0 + small) {
797
- // -------------------- hyperbolic --------------------
798
- if (ecc > 1.0 && Math.abs(nu) + 0.00001 < PI - Math.acos(1.0 / ecc)) {
799
- var sine = (Math.sqrt(ecc * ecc - 1.0) * Math.sin(nu)) / (1.0 + ecc * Math.cos(nu));
800
- e0 = Sgp4.asinh(sine);
801
- m = ecc * Sgp4.sinh(e0) - e0;
802
- }
803
- }
804
- else if (Math.abs(nu) < (168.0 * PI) / 180.0) {
805
- // ----------------- parabolic ---------------------
806
- e0 = Math.tan(nu * 0.5);
807
- m = e0 + (e0 * e0 * e0) / 3.0;
808
- }
809
- if (ecc < 1.0) {
810
- m %= 2.0 * PI;
811
- if (m < 0.0) {
812
- m += 2.0 * PI;
813
- }
814
- e0 %= 2.0 * PI;
815
- }
816
- return {
817
- e0: e0,
818
- m: m,
819
- };
820
- };
821
- // Sgp4init
822
- /*
823
- *----------------------------------------------------------------------------
824
- *
825
- * procedure sgp4
826
- *
827
- * this procedure is the sgp4 prediction model from space command. this is an
828
- * updated and combined version of sgp4 and sdp4, which were originally
829
- * published separately in spacetrack report //3. this version follows the
830
- * methodology from the aiaa paper (2006) describing the history and
831
- * development of the code.
832
- *
833
- * author : david vallado 719-573-2600 28 jun 2005
834
- *
835
- * inputs :
836
- * satrec - initialised structure from sgp4init() call.
837
- * tsince - time since epoch (minutes)
838
- *
839
- * outputs :
840
- * r - position vector km
841
- * v - velocity km/sec
842
- * return code - non-zero on error.
843
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
844
- * 2 - mean motion less than 0.0
845
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
846
- * 4 - semi-latus rectum < 0.0
847
- * 5 - epoch elements are sub-orbital
848
- * 6 - satellite has decayed
849
- *
850
- * locals :
851
- * am -
852
- * axnl, aynl -
853
- * betal -
854
- * cosim , sinim , cosomm , sinomm , cnod , snod , cos2u ,
855
- * sin2u , coseo1 , sineo1 , cosi , sini , cosip , sinip ,
856
- * cosisq , cossu , sinsu , cosu , sinu
857
- * delm -
858
- * delomg -
859
- * dndt -
860
- * eccm -
861
- * emsq -
862
- * ecose -
863
- * el2 -
864
- * eo1 -
865
- * eccp -
866
- * esine -
867
- * argpm -
868
- * argpp -
869
- * omgadf -
870
- * pl -
871
- * r -
872
- * rtemsq -
873
- * rdotl -
874
- * rl -
875
- * rvdot -
876
- * rvdotl -
877
- * su -
878
- * t2 , t3 , t4 , tc
879
- * tem5, temp , temp1 , temp2 , tempa , tempe , templ
880
- * u , ux , uy , uz , vx , vy , vz
881
- * inclm - inclination
882
- * mm - mean anomaly
883
- * nm - mean motion
884
- * nodem - right asc of ascending node
885
- * xinc -
886
- * xincp -
887
- * xl -
888
- * xlm -
889
- * mp -
890
- * xmdf -
891
- * xmx -
892
- * xmy -
893
- * nodedf -
894
- * xnode -
895
- * nodep -
896
- * np -
897
- *
898
- * coupling :
899
- * getgravconst-
900
- * dpper
901
- * dspace
902
- *
903
- * references :
904
- * hoots, roehrich, norad spacetrack report //3 1980
905
- * hoots, norad spacetrack report //6 1986
906
- * hoots, schumacher and glover 2004
907
- * vallado, crawford, hujsak, kelso 2006
908
- *----------------------------------------------------------------------------
909
- */
910
- Sgp4.propagate = function (satrec, tsince) {
911
- /* ------------------ set mathematical constants --------------- */
912
- /*
913
- * Sgp4fix divisor for divide by zero check on inclination
914
- * the old check used 1.0 + cos(PI-1.0e-9), but then compared it to
915
- * 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
916
- */
917
- /*
918
- * Sgp4fix identify constants and allow alternate values
919
- * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
920
- */
921
- var xke = satrec.xke, j2 = satrec.j2, j3oj2 = satrec.j3oj2;
922
- var vkmpersec = (satrec.radiusearthkm * satrec.xke) / 60.0;
923
- // --------------------- clear sgp4 error flag -----------------
924
- satrec.t = tsince;
925
- satrec.error = 0;
926
- // ------- update for secular gravity and atmospheric drag -----
927
- var xmdf = satrec.mo + satrec.mdot * satrec.t;
928
- var argpdf = satrec.argpo + satrec.argpdot * satrec.t;
929
- var nodedf = satrec.nodeo + satrec.nodedot * satrec.t;
930
- var argpm = argpdf;
931
- var mm = xmdf;
932
- var t2 = satrec.t * satrec.t;
933
- var nodem = nodedf + satrec.nodecf * t2;
934
- var tempa = 1.0 - satrec.cc1 * satrec.t;
935
- var tempe = satrec.bstar * satrec.cc4 * satrec.t;
936
- var templ = satrec.t2cof * t2;
937
- if (satrec.isimp !== 1) {
938
- var delomg = satrec.omgcof * satrec.t;
939
- // Sgp4fix use mutliply for speed instead of pow
940
- var delmtemp = 1.0 + satrec.eta * Math.cos(xmdf);
941
- var delm = satrec.xmcof * (delmtemp * delmtemp * delmtemp - satrec.delmo);
942
- var temp_1 = delomg + delm;
943
- mm = xmdf + temp_1;
944
- argpm = argpdf - temp_1;
945
- var t3 = t2 * satrec.t;
946
- var t4 = t3 * satrec.t;
947
- tempa = tempa - satrec.d2 * t2 - satrec.d3 * t3 - satrec.d4 * t4;
948
- tempe += satrec.bstar * satrec.cc5 * (Math.sin(mm) - satrec.sinmao);
949
- templ = templ + satrec.t3cof * t3 + t4 * (satrec.t4cof + satrec.t * satrec.t5cof);
950
- }
951
- var nm = satrec.no;
952
- var em = satrec.ecco;
953
- var inclm = satrec.inclo;
954
- if (satrec.method === 'd') {
955
- var tc = satrec.t;
956
- var dspaceResult = Sgp4.dspace_(satrec.irez, satrec.d2201, satrec.d2211, satrec.d3210, satrec.d3222, satrec.d4410, satrec.d4422, satrec.d5220, satrec.d5232, satrec.d5421, satrec.d5433, satrec.dedt, satrec.del1, satrec.del2, satrec.del3, satrec.didt, satrec.dmdt, satrec.dnodt, satrec.domdt, satrec.argpo, satrec.argpdot, satrec.t, tc, satrec.gsto, satrec.xfact, satrec.xlamo, satrec.no, satrec.atime, em, argpm, inclm, satrec.xli, mm, satrec.xni, nodem, nm);
957
- em = dspaceResult[0], argpm = dspaceResult[1], inclm = dspaceResult[2], mm = dspaceResult[3], nodem = dspaceResult[4], nm = dspaceResult[5];
958
- } // If methjod = d
959
- if (nm <= 0.0) {
960
- // Printf("// error nm %f\n", nm);
961
- satrec.error = 2;
962
- // Sgp4fix add return
963
- return { position: false, velocity: false };
964
- }
965
- var am = Math.pow((xke / nm), x2o3) * tempa * tempa;
966
- nm = xke / Math.pow(am, 1.5);
967
- em -= tempe;
968
- /*
969
- * Fix tolerance for error recognition
970
- * sgp4fix am is fixed from the previous nm check
971
- */
972
- /* istanbul ignore next | This is no longer possible*/
973
- if (em >= 1.0 || em < -0.001) {
974
- /*
975
- * || (am < 0.95)
976
- * printf("// error em %f\n", em);
977
- */
978
- satrec.error = 1;
979
- // Sgp4fix to return if there is an error in eccentricity
980
- return { position: false, velocity: false };
981
- }
982
- // Sgp4fix fix tolerance to avoid a divide by zero
983
- if (em < 1.0e-6) {
984
- em = 1.0e-6;
985
- }
986
- mm += satrec.no * templ;
987
- var xlm = mm + argpm + nodem;
988
- nodem %= TAU;
989
- argpm %= TAU;
990
- xlm %= TAU;
991
- mm = (xlm - argpm - nodem) % TAU;
992
- /*
993
- * Sgp4fix recover singly averaged mean elements
994
- * TODO: Skip these?
995
- * satrec.am = am;
996
- * satrec.em = em;
997
- * satrec.im = inclm;
998
- * satrec.Om = nodem;
999
- * satrec.om = argpm;
1000
- * satrec.mm = mm;
1001
- * satrec.nm = nm;
1002
- */
1003
- // ----------------- compute extra mean quantities -------------
1004
- var sinim = Math.sin(inclm);
1005
- var cosim = Math.cos(inclm);
1006
- // -------------------- add lunar-solar periodics --------------
1007
- var ep = em;
1008
- var xincp = inclm;
1009
- var argpp = argpm;
1010
- var nodep = nodem;
1011
- var mp = mm;
1012
- var sinip = sinim;
1013
- var cosip = cosim;
1014
- if (satrec.method === 'd') {
1015
- var dpperParameters = {
1016
- inclo: satrec.inclo,
1017
- init: 'n',
1018
- ep: ep,
1019
- inclp: xincp,
1020
- nodep: nodep,
1021
- argpp: argpp,
1022
- mp: mp,
1023
- opsmode: satrec.operationmode,
1024
- };
1025
- var dpperResult = Sgp4.dpper_(satrec, dpperParameters);
1026
- (ep = dpperResult.ep, nodep = dpperResult.nodep, argpp = dpperResult.argpp, mp = dpperResult.mp);
1027
- xincp = dpperResult.inclp;
1028
- if (xincp < 0.0) {
1029
- xincp = -xincp;
1030
- nodep += PI;
1031
- argpp -= PI;
1032
- }
1033
- if (ep < 0.0 || ep > 1.0) {
1034
- // Printf("// error ep %f\n", ep);
1035
- satrec.error = 3;
1036
- // Sgp4fix add return
1037
- return { position: false, velocity: false };
1038
- }
1039
- }
1040
- // -------------------- long period periodics ------------------
1041
- if (satrec.method === 'd') {
1042
- sinip = Math.sin(xincp);
1043
- cosip = Math.cos(xincp);
1044
- satrec.aycof = -0.5 * j3oj2 * sinip;
1045
- // Sgp4fix for divide by zero for xincp = 180 deg
1046
- if (Math.abs(cosip + 1.0) > 1.5e-12) {
1047
- satrec.xlcof = (-0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip)) / (1.0 + cosip);
1048
- }
1049
- else {
1050
- satrec.xlcof = (-0.25 * j3oj2 * sinip * (3.0 + 5.0 * cosip)) / temp4;
1051
- }
1052
- }
1053
- var axnl = ep * Math.cos(argpp);
1054
- var temp = 1.0 / (am * (1.0 - ep * ep));
1055
- var aynl = ep * Math.sin(argpp) + temp * satrec.aycof;
1056
- var xl = mp + argpp + nodep + temp * satrec.xlcof * axnl;
1057
- // --------------------- solve kepler's equation ---------------
1058
- var u = (xl - nodep) % TAU;
1059
- var eo1 = u;
1060
- var tem5 = 9999.9;
1061
- var ktr = 1;
1062
- /*
1063
- * Sgp4fix for kepler iteration
1064
- * the following iteration needs better limits on corrections
1065
- */
1066
- var coseo1, sineo1;
1067
- while (Math.abs(tem5) >= 1.0e-12 && ktr <= 10) {
1068
- sineo1 = Math.sin(eo1);
1069
- coseo1 = Math.cos(eo1);
1070
- tem5 = 1.0 - coseo1 * axnl - sineo1 * aynl;
1071
- tem5 = (u - aynl * coseo1 + axnl * sineo1 - eo1) / tem5;
1072
- if (Math.abs(tem5) >= 0.95) {
1073
- if (tem5 > 0.0) {
1074
- tem5 = 0.95;
1075
- }
1076
- else {
1077
- tem5 = -0.95;
1078
- }
1079
- }
1080
- eo1 += tem5;
1081
- ktr += 1;
1082
- }
1083
- // ------------- short period preliminary quantities -----------
1084
- var ecose = axnl * coseo1 + aynl * sineo1;
1085
- var esine = axnl * sineo1 - aynl * coseo1;
1086
- var el2 = axnl * axnl + aynl * aynl;
1087
- var pl = am * (1.0 - el2);
1088
- if (pl < 0.0) {
1089
- // Printf("// error pl %f\n", pl);
1090
- satrec.error = 4;
1091
- // Sgp4fix add return
1092
- return { position: false, velocity: false };
1093
- }
1094
- var rl = am * (1.0 - ecose);
1095
- var rdotl = (Math.sqrt(am) * esine) / rl;
1096
- var rvdotl = Math.sqrt(pl) / rl;
1097
- var betal = Math.sqrt(1.0 - el2);
1098
- temp = esine / (1.0 + betal);
1099
- var sinu = (am / rl) * (sineo1 - aynl - axnl * temp);
1100
- var cosu = (am / rl) * (coseo1 - axnl + aynl * temp);
1101
- var su = Math.atan2(sinu, cosu);
1102
- var sin2u = (cosu + cosu) * sinu;
1103
- var cos2u = 1.0 - 2.0 * sinu * sinu;
1104
- temp = 1.0 / pl;
1105
- var temp1 = 0.5 * j2 * temp;
1106
- var temp2 = temp1 * temp;
1107
- // -------------- update for short period periodics ------------
1108
- if (satrec.method === 'd') {
1109
- var cosisq = cosip * cosip;
1110
- satrec.con41 = 3.0 * cosisq - 1.0;
1111
- satrec.x1mth2 = 1.0 - cosisq;
1112
- satrec.x7thm1 = 7.0 * cosisq - 1.0;
1113
- }
1114
- var mrt = rl * (1.0 - 1.5 * temp2 * betal * satrec.con41) + 0.5 * temp1 * satrec.x1mth2 * cos2u;
1115
- /** Moved this up to reduce unnecessary computation if you are going to return false anyway */
1116
- // Sgp4fix for decaying satellites
1117
- if (mrt < 1.0) {
1118
- // Printf("// decay condition %11.6f \n",mrt);
1119
- satrec.error = 6;
1120
- return {
1121
- position: false,
1122
- velocity: false,
1123
- };
1124
- }
1125
- su -= 0.25 * temp2 * satrec.x7thm1 * sin2u;
1126
- var xnode = nodep + 1.5 * temp2 * cosip * sin2u;
1127
- var xinc = xincp + 1.5 * temp2 * cosip * sinip * cos2u;
1128
- var mvt = rdotl - (nm * temp1 * satrec.x1mth2 * sin2u) / xke;
1129
- var rvdot = rvdotl + (nm * temp1 * (satrec.x1mth2 * cos2u + 1.5 * satrec.con41)) / xke;
1130
- // --------------------- orientation vectors -------------------
1131
- var sinsu = Math.sin(su);
1132
- var cossu = Math.cos(su);
1133
- var snod = Math.sin(xnode);
1134
- var cnod = Math.cos(xnode);
1135
- var sini = Math.sin(xinc);
1136
- var cosi = Math.cos(xinc);
1137
- var xmx = -snod * cosi;
1138
- var xmy = cnod * cosi;
1139
- var ux = xmx * sinsu + cnod * cossu;
1140
- var uy = xmy * sinsu + snod * cossu;
1141
- var uz = sini * sinsu;
1142
- var vx = xmx * cossu - cnod * sinsu;
1143
- var vy = xmy * cossu - snod * sinsu;
1144
- var vz = sini * cossu;
1145
- // --------- position and velocity (in km and km/sec) ----------
1146
- var r = {
1147
- x: mrt * ux * satrec.radiusearthkm,
1148
- y: mrt * uy * satrec.radiusearthkm,
1149
- z: mrt * uz * satrec.radiusearthkm,
1150
- };
1151
- var v = {
1152
- x: (mvt * ux + rvdot * vx) * vkmpersec,
1153
- y: (mvt * uy + rvdot * vy) * vkmpersec,
1154
- z: (mvt * uz + rvdot * vz) * vkmpersec,
1155
- };
1156
- return {
1157
- position: r,
1158
- velocity: v,
1159
- };
1160
- };
1161
- /*
1162
- * -----------------------------------------------------------------------------
1163
- *
1164
- * function rv2coe_SGP4
1165
- *
1166
- * this function finds the classical orbital elements given the geocentric
1167
- * equatorial position and velocity vectors.
1168
- *
1169
- * author : david vallado 719-573-2600 21 jun 2002
1170
- *
1171
- * revisions
1172
- * vallado - fix special cases 5 sep 2002
1173
- * vallado - delete extra check in inclination code 16 oct 2002
1174
- * vallado - add constant file use 29 jun 2003
1175
- * vallado - add mu 2 apr 2007
1176
- *
1177
- * inputs description range / units
1178
- * r - ijk position vector km
1179
- * v - ijk velocity vector km / s
1180
- * mu - gravitational parameter km3 / s2
1181
- *
1182
- * outputs :
1183
- * p - semilatus rectum km
1184
- * a - semimajor axis km
1185
- * ecc - eccentricity
1186
- * incl - inclination 0.0 to pi rad
1187
- * omega - right ascension of ascending node 0.0 to 2pi rad
1188
- * argp - argument of perigee 0.0 to 2pi rad
1189
- * nu - true anomaly 0.0 to 2pi rad
1190
- * m - mean anomaly 0.0 to 2pi rad
1191
- * arglat - argument of latitude (ci) 0.0 to 2pi rad
1192
- * truelon - true longitude (ce) 0.0 to 2pi rad
1193
- * lonper - longitude of periapsis (ee) 0.0 to 2pi rad
1194
- *
1195
- * locals :
1196
- * hbar - angular momentum h vector km2 / s
1197
- * ebar - eccentricity e vector
1198
- * nbar - line of nodes n vector
1199
- * c1 - v**2 - u/r
1200
- * rdotv - r dot v
1201
- * hk - hk unit vector
1202
- * sme - specfic mechanical energy km2 / s2
1203
- * i - index
1204
- * e - eccentric, parabolic,
1205
- * hyperbolic anomaly rad
1206
- * temp - temporary variable
1207
- * typeorbit - type of orbit ee, ei, ce, ci
1208
- *
1209
- * coupling :
1210
- * mag - magnitude of a vector
1211
- * cross - cross product of two vectors
1212
- * angle - find the angle between two vectors
1213
- * newtonnu - find the mean anomaly
1214
- *
1215
- * references :
1216
- * vallado 2013, 113, alg 9, ex 2-5
1217
- * ---------------------------------------------------------------------------
1218
- */
1219
- Sgp4.rv2coe = function (r, v, mus) {
1220
- var nbar = [0, 0, 0];
1221
- var ebar = [0, 0, 0];
1222
- var p;
1223
- var a;
1224
- var ecc;
1225
- var incl;
1226
- var omega;
1227
- var argp;
1228
- var nu;
1229
- var m;
1230
- var arglat;
1231
- var truelon;
1232
- var lonper;
1233
- var rdotv;
1234
- var magn;
1235
- var hk;
1236
- var sme;
1237
- var i;
1238
- /*
1239
- * Switch this to an integer msvs seems to have probelms with this and strncpy_s
1240
- * char typeorbit[2];
1241
- */
1242
- var typeorbit;
1243
- /*
1244
- * Here
1245
- * typeorbit = 1 = 'ei'
1246
- * typeorbit = 2 = 'ce'
1247
- * typeorbit = 3 = 'ci'
1248
- * typeorbit = 4 = 'ee'
1249
- */
1250
- var halfpi = 0.5 * PI;
1251
- var small = 0.00000001;
1252
- var unknown = 999999.1; /** Ootk -- original undefined is illegal in JS */
1253
- var infinite = 999999.9;
1254
- // ------------------------- implementation -----------------
1255
- var magr = Sgp4.mag(r);
1256
- var magv = Sgp4.mag(v);
1257
- // ------------------ find h n and e vectors ----------------
1258
- var hbar = Sgp4.cross(r, v);
1259
- var magh = Sgp4.mag(hbar);
1260
- if (magh > small) {
1261
- nbar[0] = -hbar[1];
1262
- nbar[1] = hbar[0];
1263
- nbar[2] = 0.0;
1264
- magn = Sgp4.mag(nbar);
1265
- var c1 = magv * magv - mus / magr;
1266
- rdotv = Sgp4.dot(r, v);
1267
- for (i = 0; i <= 2; i++) {
1268
- ebar[i] = (c1 * r[i] - rdotv * v[i]) / mus;
1269
- }
1270
- ecc = Sgp4.mag(ebar);
1271
- // ------------ find a e and semi-latus rectum ----------
1272
- sme = magv * magv * 0.5 - mus / magr;
1273
- if (Math.abs(sme) > small) {
1274
- a = -mus / (2.0 * sme);
1275
- }
1276
- else {
1277
- a = infinite;
1278
- }
1279
- p = (magh * magh) / mus;
1280
- // ----------------- find inclination -------------------
1281
- hk = hbar[2] / magh;
1282
- incl = Math.acos(hk);
1283
- /*
1284
- * -------- determine type of orbit for later use --------
1285
- * ------ elliptical, parabolic, hyperbolic inclined -------
1286
- */
1287
- typeorbit = 1;
1288
- if (ecc < small) {
1289
- // ---------------- circular equatorial ---------------
1290
- if (incl < small || Math.abs(incl - PI) < small) {
1291
- typeorbit = 2;
1292
- }
1293
- else {
1294
- // -------------- circular inclined ---------------
1295
- typeorbit = 3;
1296
- }
1297
- }
1298
- else {
1299
- // - elliptical, parabolic, hyperbolic equatorial --
1300
- if (incl < small || Math.abs(incl - PI) < small) {
1301
- typeorbit = 4;
1302
- }
1303
- }
1304
- // ---------- find right ascension of the ascending node ------------
1305
- if (magn > small) {
1306
- var temp = nbar[0] / magn;
1307
- if (Math.abs(temp) > 1.0) {
1308
- temp = Sgp4.sgn(temp);
1309
- }
1310
- omega = Math.acos(temp);
1311
- if (nbar[1] < 0.0) {
1312
- omega = TAU - omega;
1313
- }
1314
- }
1315
- else {
1316
- omega = unknown;
1317
- }
1318
- // ---------------- find argument of perigee ---------------
1319
- if (typeorbit === 1) {
1320
- argp = Sgp4.angle(nbar, ebar);
1321
- if (ebar[2] < 0.0) {
1322
- argp = TAU - argp;
1323
- }
1324
- }
1325
- else {
1326
- argp = unknown;
1327
- }
1328
- // ------------ find true anomaly at epoch -------------
1329
- if (typeorbit === 1 || typeorbit === 4) {
1330
- nu = Sgp4.angle(ebar, r);
1331
- if (rdotv < 0.0) {
1332
- nu = TAU - nu;
1333
- }
1334
- }
1335
- else {
1336
- nu = unknown;
1337
- }
1338
- // ---- find argument of latitude - circular inclined -----
1339
- if (typeorbit === 3) {
1340
- arglat = Sgp4.angle(nbar, r);
1341
- if (r[2] < 0.0) {
1342
- arglat = TAU - arglat;
1343
- }
1344
- m = arglat;
1345
- }
1346
- else {
1347
- arglat = unknown;
1348
- }
1349
- if (ecc > small && typeorbit === 4) {
1350
- var temp = ebar[0] / ecc;
1351
- if (Math.abs(temp) > 1.0) {
1352
- temp = Sgp4.sgn(temp);
1353
- }
1354
- lonper = Math.acos(temp);
1355
- if (ebar[1] < 0.0) {
1356
- lonper = TAU - lonper;
1357
- }
1358
- if (incl > halfpi) {
1359
- lonper = TAU - lonper;
1360
- }
1361
- }
1362
- else {
1363
- lonper = unknown;
1364
- }
1365
- // -------- find true longitude - circular equatorial ------
1366
- if (magr > small && typeorbit === 2) {
1367
- var temp = r[0] / magr;
1368
- if (Math.abs(temp) > 1.0) {
1369
- temp = Sgp4.sgn(temp);
1370
- }
1371
- truelon = Math.acos(temp);
1372
- if (r[1] < 0.0) {
1373
- truelon = TAU - truelon;
1374
- }
1375
- if (incl > halfpi) {
1376
- truelon = TAU - truelon;
1377
- }
1378
- m = truelon;
1379
- }
1380
- else {
1381
- truelon = unknown;
1382
- }
1383
- // ------------ find mean anomaly for all orbits -----------
1384
- if (typeorbit === 1 || typeorbit === 4) {
1385
- m = Sgp4.newtonnu(ecc, nu).m;
1386
- }
1387
- }
1388
- else {
1389
- p = unknown;
1390
- a = unknown;
1391
- ecc = unknown;
1392
- incl = unknown;
1393
- omega = unknown;
1394
- argp = unknown;
1395
- nu = unknown;
1396
- m = unknown;
1397
- arglat = unknown;
1398
- truelon = unknown;
1399
- lonper = unknown;
1400
- }
1401
- return {
1402
- p: p,
1403
- a: a,
1404
- ecc: ecc,
1405
- incl: incl,
1406
- omega: omega,
1407
- argp: argp,
1408
- nu: nu,
1409
- m: m,
1410
- arglat: arglat,
1411
- truelon: truelon,
1412
- lonper: lonper,
1413
- };
1414
- };
1415
- Sgp4.sgn = function (x) {
1416
- if (x < 0.0) {
1417
- return -1.0;
1418
- }
1419
- return 1.0;
1420
- };
1421
- // Newtonnu
1422
- Sgp4.sinh = function (x) {
1423
- return (Math.exp(x) - Math.exp(-x)) / 2;
1424
- };
1425
- // #endregion Public Static Methods (15)
1426
- // #region Private Static Methods (7)
1427
- /*
1428
- * -----------------------------------------------------------------------------
1429
- *
1430
- * procedure dpper
1431
- *
1432
- * this procedure provides deep space long period periodic contributions
1433
- * to the mean elements. by design, these periodics are zero at epoch.
1434
- * this used to be dscom which included initialization, but it's really a
1435
- * recurring function.
1436
- *
1437
- * author : david vallado 719-573-2600 28 jun 2005
1438
- *
1439
- * inputs :
1440
- * e3 -
1441
- * ee2 -
1442
- * peo -
1443
- * pgho -
1444
- * pho -
1445
- * PInco -
1446
- * plo -
1447
- * se2 , se3 , sgh2, sgh3, sgh4, sh2, sh3, si2, si3, sl2, sl3, sl4 -
1448
- * t -
1449
- * xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
1450
- * zmol -
1451
- * zmos -
1452
- * ep - eccentricity 0.0 - 1.0
1453
- * inclo - inclination - needed for lyddane modification
1454
- * nodep - right ascension of ascending node
1455
- * argpp - argument of perigee
1456
- * mp - mean anomaly
1457
- *
1458
- * outputs :
1459
- * ep - eccentricity 0.0 - 1.0
1460
- * inclp - inclination
1461
- * nodep - right ascension of ascending node
1462
- * argpp - argument of perigee
1463
- * mp - mean anomaly
1464
- *
1465
- * locals :
1466
- * alfdp -
1467
- * betdp -
1468
- * cosip , sinip , cosop , sinop ,
1469
- * dalf -
1470
- * dbet -
1471
- * dls -
1472
- * f2, f3 -
1473
- * pe -
1474
- * pgh -
1475
- * ph -
1476
- * PInc -
1477
- * pl -
1478
- * sel , ses , sghl , sghs , shl , shs , sil , sinzf , sis ,
1479
- * sll , sls
1480
- * xls -
1481
- * xnoh -
1482
- * zf -
1483
- * zm -
1484
- *
1485
- * coupling :
1486
- * none.
1487
- *
1488
- * references :
1489
- * hoots, roehrich, norad spacetrack report #3 1980
1490
- * hoots, norad spacetrack report #6 1986
1491
- * hoots, schumacher and glover 2004
1492
- * vallado, crawford, hujsak, kelso 2006
1493
- * ----------------------------------------------------------------------------
1494
- */
1495
- Sgp4.dpper_ = function (satrec, options) {
1496
- var e3 = satrec.e3, ee2 = satrec.ee2, peo = satrec.peo, pgho = satrec.pgho, pho = satrec.pho, PInco = satrec.PInco, plo = satrec.plo, se2 = satrec.se2, se3 = satrec.se3, sgh2 = satrec.sgh2, sgh3 = satrec.sgh3, sgh4 = satrec.sgh4, sh2 = satrec.sh2, sh3 = satrec.sh3, si2 = satrec.si2, si3 = satrec.si3, sl2 = satrec.sl2, sl3 = satrec.sl3, sl4 = satrec.sl4, t = satrec.t, xgh2 = satrec.xgh2, xgh3 = satrec.xgh3, xgh4 = satrec.xgh4, xh2 = satrec.xh2, xh3 = satrec.xh3, xi2 = satrec.xi2, xi3 = satrec.xi3, xl2 = satrec.xl2, xl3 = satrec.xl3, xl4 = satrec.xl4, zmol = satrec.zmol, zmos = satrec.zmos;
1497
- var ep = options.ep, inclp = options.inclp, nodep = options.nodep, argpp = options.argpp, mp = options.mp;
1498
- var _a = options.opsmode, opsmode = _a === void 0 ? 'i' : _a, init = options.init;
1499
- // ---------------------- constants -----------------------------
1500
- /** Ootk -- Some variables imported from outside the class at the top */
1501
- var zns = 1.19459e-5;
1502
- var zes = 0.01675;
1503
- var znl = 1.5835218e-4;
1504
- var zel = 0.0549;
1505
- // --------------- calculate time varying periodics -----------
1506
- var zm = zmos + zns * t;
1507
- // Be sure that the initial call has time set to zero
1508
- if (init === 'y') {
1509
- zm = zmos;
1510
- }
1511
- var zf = zm + 2.0 * zes * Math.sin(zm);
1512
- var sinzf = Math.sin(zf);
1513
- var f2 = 0.5 * sinzf * sinzf - 0.25;
1514
- var f3 = -0.5 * sinzf * Math.cos(zf);
1515
- var ses = se2 * f2 + se3 * f3;
1516
- var sis = si2 * f2 + si3 * f3;
1517
- var sls = sl2 * f2 + sl3 * f3 + sl4 * sinzf;
1518
- var sghs = sgh2 * f2 + sgh3 * f3 + sgh4 * sinzf;
1519
- var shs = sh2 * f2 + sh3 * f3;
1520
- zm = zmol + znl * t;
1521
- if (init === 'y') {
1522
- zm = zmol;
1523
- }
1524
- zf = zm + 2.0 * zel * Math.sin(zm);
1525
- sinzf = Math.sin(zf);
1526
- f2 = 0.5 * sinzf * sinzf - 0.25;
1527
- f3 = -0.5 * sinzf * Math.cos(zf);
1528
- var sel = ee2 * f2 + e3 * f3;
1529
- var sil = xi2 * f2 + xi3 * f3;
1530
- var sll = xl2 * f2 + xl3 * f3 + xl4 * sinzf;
1531
- var sghl = xgh2 * f2 + xgh3 * f3 + xgh4 * sinzf;
1532
- var shll = xh2 * f2 + xh3 * f3;
1533
- var pe = ses + sel;
1534
- var PInc = sis + sil;
1535
- var pl = sls + sll;
1536
- var pgh = sghs + sghl;
1537
- var ph = shs + shll;
1538
- if (init === 'n') {
1539
- pe -= peo;
1540
- PInc -= PInco;
1541
- pl -= plo;
1542
- pgh -= pgho;
1543
- ph -= pho;
1544
- inclp += PInc;
1545
- ep += pe;
1546
- var sinip = Math.sin(inclp);
1547
- var cosip = Math.cos(inclp);
1548
- /* ----------------- apply periodics directly ------------ */
1549
- /*
1550
- * Sgp4fix for lyddane choice
1551
- * strn3 used original inclination - this is technically feasible
1552
- * gsfc used perturbed inclination - also technically feasible
1553
- * probably best to readjust the 0.2 limit value and limit discontinuity
1554
- * 0.2 rad = 11.45916 deg
1555
- * use next line for original strn3 approach and original inclination
1556
- * if (inclo >= 0.2)
1557
- * use next line for gsfc version and perturbed inclination
1558
- */
1559
- if (inclp >= 0.2) {
1560
- ph /= sinip;
1561
- pgh -= cosip * ph;
1562
- argpp += pgh;
1563
- nodep += ph;
1564
- mp += pl;
1565
- }
1566
- else {
1567
- // ---- apply periodics with lyddane modification ----
1568
- var sinop = Math.sin(nodep);
1569
- var cosop = Math.cos(nodep);
1570
- var alfdp = sinip * sinop;
1571
- var betdp = sinip * cosop;
1572
- var dalf = ph * cosop + PInc * cosip * sinop;
1573
- var dbet = -ph * sinop + PInc * cosip * cosop;
1574
- alfdp += dalf;
1575
- betdp += dbet;
1576
- nodep %= TAU;
1577
- /*
1578
- * Sgp4fix for afspc written intrinsic functions
1579
- * nodep used without a trigonometric function ahead
1580
- */
1581
- /* istanbul ignore next */
1582
- if (nodep < 0.0 && opsmode === 'a') {
1583
- nodep += TAU;
1584
- }
1585
- var xls = mp + argpp + cosip * nodep;
1586
- var dls = pl + pgh - PInc * nodep * sinip;
1587
- xls += dls;
1588
- var xnoh = nodep;
1589
- nodep = Math.atan2(alfdp, betdp);
1590
- /*
1591
- * Sgp4fix for afspc written intrinsic functions
1592
- * nodep used without a trigonometric function ahead
1593
- */
1594
- /* istanbul ignore next */
1595
- if (nodep < 0.0 && opsmode === 'a') {
1596
- nodep += TAU;
1597
- }
1598
- if (Math.abs(xnoh - nodep) > PI) {
1599
- /* istanbul ignore next */
1600
- if (nodep < xnoh) {
1601
- nodep += TAU;
1602
- }
1603
- else {
1604
- nodep -= TAU;
1605
- }
1606
- }
1607
- mp += pl;
1608
- argpp = xls - mp - cosip * nodep;
1609
- }
1610
- } // If init == 'n'
1611
- return {
1612
- ep: ep,
1613
- inclp: inclp,
1614
- nodep: nodep,
1615
- argpp: argpp,
1616
- mp: mp,
1617
- };
1618
- };
1619
- // Dpper
1620
- /*
1621
- *-----------------------------------------------------------------------------
1622
- *
1623
- * procedure dscom
1624
- *
1625
- * this procedure provides deep space common items used by both the secular
1626
- * and periodics subroutines. input is provided as shown. this routine
1627
- * used to be called dpper, but the functions inside weren't well organized.
1628
- *
1629
- * author : david vallado 719-573-2600 28 jun 2005
1630
- *
1631
- * inputs :
1632
- * epoch -
1633
- * ep - eccentricity
1634
- * argpp - argument of perigee
1635
- * tc -
1636
- * inclp - inclination
1637
- * nodep - right ascension of ascending node
1638
- * np - mean motion
1639
- *
1640
- * outputs :
1641
- * sinim , cosim , sinomm , cosomm , snodm , cnodm
1642
- * day -
1643
- * e3 -
1644
- * ee2 -
1645
- * em - eccentricity
1646
- * emsq - eccentricity squared
1647
- * gam -
1648
- * peo -
1649
- * pgho -
1650
- * pho -
1651
- * PInco -
1652
- * plo -
1653
- * rtemsq -
1654
- * se2, se3 -
1655
- * sgh2, sgh3, sgh4 -
1656
- * sh2, sh3, si2, si3, sl2, sl3, sl4 -
1657
- * s1, s2, s3, s4, s5, s6, s7 -
1658
- * ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz2, sz3 -
1659
- * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
1660
- * xgh2, xgh3, xgh4, xh2, xh3, xi2, xi3, xl2, xl3, xl4 -
1661
- * nm - mean motion
1662
- * z1, z2, z3, z11, z12, z13, z21, z22, z23, z31, z32, z33 -
1663
- * zmol -
1664
- * zmos -
1665
- *
1666
- * locals :
1667
- * a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 -
1668
- * betasq -
1669
- * cc -
1670
- * ctem, stem -
1671
- * x1, x2, x3, x4, x5, x6, x7, x8 -
1672
- * xnodce -
1673
- * xnoi -
1674
- * zcosg , zsing , zcosgl , zsingl , zcosh , zsinh , zcoshl , zsinhl ,
1675
- * zcosi , zsini , zcosil , zsinil ,
1676
- * zx -
1677
- * zy -
1678
- *
1679
- * coupling :
1680
- * none.
1681
- *
1682
- * references :
1683
- * hoots, roehrich, norad spacetrack report #3 1980
1684
- * hoots, norad spacetrack report #6 1986
1685
- * hoots, schumacher and glover 2004
1686
- * vallado, crawford, hujsak, kelso 2006
1687
- *----------------------------------------------------------------------------
1688
- */
1689
- Sgp4.dscom_ = function (options) {
1690
- var epoch = options.epoch, ep = options.ep, argpp = options.argpp, tc = options.tc, inclp = options.inclp, nodep = options.nodep, np = options.np;
1691
- // -------------------------- constants -------------------------
1692
- /** Ootk -- Some variables imported from outside the class at the top */
1693
- var zes = 0.01675;
1694
- var zel = 0.0549;
1695
- var c1ss = 2.9864797e-6;
1696
- var c1l = 4.7968065e-7;
1697
- var zsinis = 0.39785416;
1698
- var zcosis = 0.91744867;
1699
- var zcosgs = 0.1945905;
1700
- var zsings = -0.98088458;
1701
- var TAU = 2.0 * Math.PI;
1702
- // --------------------- local variables ------------------------
1703
- var s1, s2, s3, s4, s5, s6, s7, ss1, ss2, ss3, ss4, ss5, ss6, ss7, sz1, sz11, sz12, sz13, sz2, sz21, sz22, sz23, sz3, sz31, sz32, sz33, z1, z11, z12, z13, z2, z21, z22, z23, z3, z31, z32, z33;
1704
- var nm = np;
1705
- var em = ep;
1706
- var snodm = Math.sin(nodep);
1707
- var cnodm = Math.cos(nodep);
1708
- var sinomm = Math.sin(argpp);
1709
- var cosomm = Math.cos(argpp);
1710
- var sinim = Math.sin(inclp);
1711
- var cosim = Math.cos(inclp);
1712
- var emsq = em * em;
1713
- var betasq = 1.0 - emsq;
1714
- var rtemsq = Math.sqrt(betasq);
1715
- // ----------------- initialize lunar solar terms ---------------
1716
- var peo = 0.0;
1717
- var PInco = 0.0;
1718
- var plo = 0.0;
1719
- var pgho = 0.0;
1720
- var pho = 0.0;
1721
- var day = epoch + 18261.5 + tc / 1440.0;
1722
- var xnodce = (4.523602 - 9.2422029e-4 * day) % TAU;
1723
- var stem = Math.sin(xnodce);
1724
- var ctem = Math.cos(xnodce);
1725
- var zcosil = 0.91375164 - 0.03568096 * ctem;
1726
- var zsinil = Math.sqrt(1.0 - zcosil * zcosil);
1727
- var zsinhl = (0.089683511 * stem) / zsinil;
1728
- var zcoshl = Math.sqrt(1.0 - zsinhl * zsinhl);
1729
- var gam = 5.8351514 + 0.001944368 * day;
1730
- var zx = (0.39785416 * stem) / zsinil;
1731
- var zy = zcoshl * ctem + 0.91744867 * zsinhl * stem;
1732
- zx = Math.atan2(zx, zy);
1733
- zx += gam - xnodce;
1734
- var zcosgl = Math.cos(zx);
1735
- var zsingl = Math.sin(zx);
1736
- // ------------------------- do solar terms ---------------------
1737
- var zcosg = zcosgs;
1738
- var zsing = zsings;
1739
- var zcosi = zcosis;
1740
- var zsini = zsinis;
1741
- var zcosh = cnodm;
1742
- var zsinh = snodm;
1743
- var cc = c1ss;
1744
- var xnoi = 1.0 / nm;
1745
- for (var lsflg = 1; lsflg <= 2; lsflg++) {
1746
- var a1 = zcosg * zcosh + zsing * zcosi * zsinh;
1747
- var a3 = -zsing * zcosh + zcosg * zcosi * zsinh;
1748
- var a7 = -zcosg * zsinh + zsing * zcosi * zcosh;
1749
- var a8 = zsing * zsini;
1750
- var a9 = zsing * zsinh + zcosg * zcosi * zcosh;
1751
- var a10 = zcosg * zsini;
1752
- var a2 = cosim * a7 + sinim * a8;
1753
- var a4 = cosim * a9 + sinim * a10;
1754
- var a5 = -sinim * a7 + cosim * a8;
1755
- var a6 = -sinim * a9 + cosim * a10;
1756
- var x1 = a1 * cosomm + a2 * sinomm;
1757
- var x2 = a3 * cosomm + a4 * sinomm;
1758
- var x3 = -a1 * sinomm + a2 * cosomm;
1759
- var x4 = -a3 * sinomm + a4 * cosomm;
1760
- var x5 = a5 * sinomm;
1761
- var x6 = a6 * sinomm;
1762
- var x7 = a5 * cosomm;
1763
- var x8 = a6 * cosomm;
1764
- z31 = 12.0 * x1 * x1 - 3.0 * x3 * x3;
1765
- z32 = 24.0 * x1 * x2 - 6.0 * x3 * x4;
1766
- z33 = 12.0 * x2 * x2 - 3.0 * x4 * x4;
1767
- z1 = 3.0 * (a1 * a1 + a2 * a2) + z31 * emsq;
1768
- z2 = 6.0 * (a1 * a3 + a2 * a4) + z32 * emsq;
1769
- z3 = 3.0 * (a3 * a3 + a4 * a4) + z33 * emsq;
1770
- z11 = -6.0 * a1 * a5 + emsq * (-24.0 * x1 * x7 - 6.0 * x3 * x5);
1771
- z12 = -6.0 * (a1 * a6 + a3 * a5) + emsq * (-24.0 * (x2 * x7 + x1 * x8) + -6.0 * (x3 * x6 + x4 * x5));
1772
- z13 = -6.0 * a3 * a6 + emsq * (-24.0 * x2 * x8 - 6.0 * x4 * x6);
1773
- z21 = 6.0 * a2 * a5 + emsq * (24.0 * x1 * x5 - 6.0 * x3 * x7);
1774
- z22 = 6.0 * (a4 * a5 + a2 * a6) + emsq * (24.0 * (x2 * x5 + x1 * x6) - 6.0 * (x4 * x7 + x3 * x8));
1775
- z23 = 6.0 * a4 * a6 + emsq * (24.0 * x2 * x6 - 6.0 * x4 * x8);
1776
- z1 = z1 + z1 + betasq * z31;
1777
- z2 = z2 + z2 + betasq * z32;
1778
- z3 = z3 + z3 + betasq * z33;
1779
- s3 = cc * xnoi;
1780
- s2 = (-0.5 * s3) / rtemsq;
1781
- s4 = s3 * rtemsq;
1782
- s1 = -15.0 * em * s4;
1783
- s5 = x1 * x3 + x2 * x4;
1784
- s6 = x2 * x3 + x1 * x4;
1785
- s7 = x2 * x4 - x1 * x3;
1786
- // ----------------------- do lunar terms -------------------
1787
- if (lsflg === 1) {
1788
- ss1 = s1;
1789
- ss2 = s2;
1790
- ss3 = s3;
1791
- ss4 = s4;
1792
- ss5 = s5;
1793
- ss6 = s6;
1794
- ss7 = s7;
1795
- sz1 = z1;
1796
- sz2 = z2;
1797
- sz3 = z3;
1798
- sz11 = z11;
1799
- sz12 = z12;
1800
- sz13 = z13;
1801
- sz21 = z21;
1802
- sz22 = z22;
1803
- sz23 = z23;
1804
- sz31 = z31;
1805
- sz32 = z32;
1806
- sz33 = z33;
1807
- zcosg = zcosgl;
1808
- zsing = zsingl;
1809
- zcosi = zcosil;
1810
- zsini = zsinil;
1811
- zcosh = zcoshl * cnodm + zsinhl * snodm;
1812
- zsinh = snodm * zcoshl - cnodm * zsinhl;
1813
- cc = c1l;
1814
- }
1815
- }
1816
- var zmol = (4.7199672 + (0.2299715 * day - gam)) % TAU;
1817
- var zmos = (6.2565837 + 0.017201977 * day) % TAU;
1818
- // ------------------------ do solar terms ----------------------
1819
- var se2 = 2.0 * ss1 * ss6;
1820
- var se3 = 2.0 * ss1 * ss7;
1821
- var si2 = 2.0 * ss2 * sz12;
1822
- var si3 = 2.0 * ss2 * (sz13 - sz11);
1823
- var sl2 = -2.0 * ss3 * sz2;
1824
- var sl3 = -2.0 * ss3 * (sz3 - sz1);
1825
- var sl4 = -2.0 * ss3 * (-21.0 - 9.0 * emsq) * zes;
1826
- var sgh2 = 2.0 * ss4 * sz32;
1827
- var sgh3 = 2.0 * ss4 * (sz33 - sz31);
1828
- var sgh4 = -18.0 * ss4 * zes;
1829
- var sh2 = -2.0 * ss2 * sz22;
1830
- var sh3 = -2.0 * ss2 * (sz23 - sz21);
1831
- // ------------------------ do lunar terms ----------------------
1832
- var ee2 = 2.0 * s1 * s6;
1833
- var e3 = 2.0 * s1 * s7;
1834
- var xi2 = 2.0 * s2 * z12;
1835
- var xi3 = 2.0 * s2 * (z13 - z11);
1836
- var xl2 = -2.0 * s3 * z2;
1837
- var xl3 = -2.0 * s3 * (z3 - z1);
1838
- var xl4 = -2.0 * s3 * (-21.0 - 9.0 * emsq) * zel;
1839
- var xgh2 = 2.0 * s4 * z32;
1840
- var xgh3 = 2.0 * s4 * (z33 - z31);
1841
- var xgh4 = -18.0 * s4 * zel;
1842
- var xh2 = -2.0 * s2 * z22;
1843
- var xh3 = -2.0 * s2 * (z23 - z21);
1844
- return {
1845
- snodm: snodm,
1846
- cnodm: cnodm,
1847
- sinim: sinim,
1848
- cosim: cosim,
1849
- sinomm: sinomm,
1850
- cosomm: cosomm,
1851
- day: day,
1852
- e3: e3,
1853
- ee2: ee2,
1854
- em: em,
1855
- emsq: emsq,
1856
- gam: gam,
1857
- peo: peo,
1858
- pgho: pgho,
1859
- pho: pho,
1860
- PInco: PInco,
1861
- plo: plo,
1862
- rtemsq: rtemsq,
1863
- se2: se2,
1864
- se3: se3,
1865
- sgh2: sgh2,
1866
- sgh3: sgh3,
1867
- sgh4: sgh4,
1868
- sh2: sh2,
1869
- sh3: sh3,
1870
- si2: si2,
1871
- si3: si3,
1872
- sl2: sl2,
1873
- sl3: sl3,
1874
- sl4: sl4,
1875
- s1: s1,
1876
- s2: s2,
1877
- s3: s3,
1878
- s4: s4,
1879
- s5: s5,
1880
- s6: s6,
1881
- s7: s7,
1882
- ss1: ss1,
1883
- ss2: ss2,
1884
- ss3: ss3,
1885
- ss4: ss4,
1886
- ss5: ss5,
1887
- ss6: ss6,
1888
- ss7: ss7,
1889
- sz1: sz1,
1890
- sz2: sz2,
1891
- sz3: sz3,
1892
- sz11: sz11,
1893
- sz12: sz12,
1894
- sz13: sz13,
1895
- sz21: sz21,
1896
- sz22: sz22,
1897
- sz23: sz23,
1898
- sz31: sz31,
1899
- sz32: sz32,
1900
- sz33: sz33,
1901
- xgh2: xgh2,
1902
- xgh3: xgh3,
1903
- xgh4: xgh4,
1904
- xh2: xh2,
1905
- xh3: xh3,
1906
- xi2: xi2,
1907
- xi3: xi3,
1908
- xl2: xl2,
1909
- xl3: xl3,
1910
- xl4: xl4,
1911
- nm: nm,
1912
- z1: z1,
1913
- z2: z2,
1914
- z3: z3,
1915
- z11: z11,
1916
- z12: z12,
1917
- z13: z13,
1918
- z21: z21,
1919
- z22: z22,
1920
- z23: z23,
1921
- z31: z31,
1922
- z32: z32,
1923
- z33: z33,
1924
- zmol: zmol,
1925
- zmos: zmos,
1926
- };
1927
- };
1928
- // Dscom
1929
- /*
1930
- *-----------------------------------------------------------------------------
1931
- *
1932
- * procedure dsinit
1933
- *
1934
- * this procedure provides deep space contributions to mean motion dot due
1935
- * to geopotential resonance with half day and one day orbits.
1936
- *
1937
- * author : david vallado 719-573-2600 28 jun 2005
1938
- *
1939
- * inputs :
1940
- * cosim, sinim-
1941
- * emsq - eccentricity squared
1942
- * argpo - argument of perigee
1943
- * s1, s2, s3, s4, s5 -
1944
- * ss1, ss2, ss3, ss4, ss5 -
1945
- * sz1, sz3, sz11, sz13, sz21, sz23, sz31, sz33 -
1946
- * t - time
1947
- * tc -
1948
- * gsto - greenwich sidereal time rad
1949
- * mo - mean anomaly
1950
- * mdot - mean anomaly dot (rate)
1951
- * no - mean motion
1952
- * nodeo - right ascension of ascending node
1953
- * nodedot - right ascension of ascending node dot (rate)
1954
- * xPIdot -
1955
- * z1, z3, z11, z13, z21, z23, z31, z33 -
1956
- * eccm - eccentricity
1957
- * argpm - argument of perigee
1958
- * inclm - inclination
1959
- * mm - mean anomaly
1960
- * xn - mean motion
1961
- * nodem - right ascension of ascending node
1962
- *
1963
- * outputs :
1964
- * em - eccentricity
1965
- * argpm - argument of perigee
1966
- * inclm - inclination
1967
- * mm - mean anomaly
1968
- * nm - mean motion
1969
- * nodem - right ascension of ascending node
1970
- * irez - flag for resonance 0-none, 1-one day, 2-half day
1971
- * atime -
1972
- * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
1973
- * dedt -
1974
- * didt -
1975
- * dmdt -
1976
- * dndt -
1977
- * dnodt -
1978
- * domdt -
1979
- * del1, del2, del3 -
1980
- * ses , sghl , sghs , sgs , shl , shs , sis , sls
1981
- * theta -
1982
- * xfact -
1983
- * xlamo -
1984
- * xli -
1985
- * xni
1986
- *
1987
- * locals :
1988
- * ainv2 -
1989
- * aonv -
1990
- * cosisq -
1991
- * eoc -
1992
- * f220, f221, f311, f321, f322, f330, f441, f442, f522, f523, f542, f543 -
1993
- * g200, g201, g211, g300, g310, g322, g410, g422, g520, g521, g532, g533 -
1994
- * sini2 -
1995
- * temp -
1996
- * temp1 -
1997
- * theta -
1998
- * xno2 -
1999
- *
2000
- * coupling :
2001
- * getgravconst
2002
- *
2003
- * references :
2004
- * hoots, roehrich, norad spacetrack report #3 1980
2005
- * hoots, norad spacetrack report #6 1986
2006
- * hoots, schumacher and glover 2004
2007
- * vallado, crawford, hujsak, kelso 2006
2008
- *----------------------------------------------------------------------------
2009
- */
2010
- Sgp4.dsinit_ = function (options) {
2011
- /*
2012
- * Sgp4fix just send in xke as a constant and eliminate getgravconst call
2013
- * gravconsttype whichconst,
2014
- */
2015
- var xke = options.xke, cosim = options.cosim, argpo = options.argpo, s1 = options.s1, s2 = options.s2, s3 = options.s3, s4 = options.s4, s5 = options.s5, sinim = options.sinim, ss1 = options.ss1, ss2 = options.ss2, ss3 = options.ss3, ss4 = options.ss4, ss5 = options.ss5, sz1 = options.sz1, sz3 = options.sz3, sz11 = options.sz11, sz13 = options.sz13, sz21 = options.sz21, sz23 = options.sz23, sz31 = options.sz31, sz33 = options.sz33, t = options.t, tc = options.tc, gsto = options.gsto, mo = options.mo, mdot = options.mdot, no = options.no, nodeo = options.nodeo, nodedot = options.nodedot, xPIdot = options.xPIdot, z1 = options.z1, z3 = options.z3, z11 = options.z11, z13 = options.z13, z21 = options.z21, z23 = options.z23, z31 = options.z31, z33 = options.z33, ecco = options.ecco, eccsq = options.eccsq;
2016
- var emsq = options.emsq, em = options.em, argpm = options.argpm, inclm = options.inclm, mm = options.mm, nm = options.nm, nodem = options.nodem, irez = options.irez, atime = options.atime, d2201 = options.d2201, d2211 = options.d2211, d3210 = options.d3210, d3222 = options.d3222, d4410 = options.d4410, d4422 = options.d4422, d5220 = options.d5220, d5232 = options.d5232, d5421 = options.d5421, d5433 = options.d5433, dedt = options.dedt, didt = options.didt, dmdt = options.dmdt, dnodt = options.dnodt, domdt = options.domdt, del1 = options.del1, del2 = options.del2, del3 = options.del3, xfact = options.xfact, xlamo = options.xlamo, xli = options.xli, xni = options.xni;
2017
- /* --------------------- local variables ------------------------ */
2018
- /** Ootk -- Some variables imported from outside the class at the top */
2019
- var q22 = 1.7891679e-6;
2020
- var q31 = 2.1460748e-6;
2021
- var q33 = 2.2123015e-7;
2022
- var root22 = 1.7891679e-6;
2023
- var root44 = 7.3636953e-9;
2024
- var root54 = 2.1765803e-9;
2025
- // IDEA: Any way to fix this?
2026
- // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
2027
- var rptim = 4.37526908801129966e-3; // Equates to 7.29211514668855e-5 rad/sec
2028
- var root32 = 3.7393792e-7;
2029
- var root52 = 1.1428639e-7;
2030
- var x2o3 = 2.0 / 3.0;
2031
- var znl = 1.5835218e-4;
2032
- var zns = 1.19459e-5;
2033
- /*
2034
- * Sgp4fix identify constants and allow alternate values
2035
- * just xke is used here so pass it in rather than have multiple calls
2036
- * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
2037
- */
2038
- // -------------------- deep space initialization ------------
2039
- irez = 0;
2040
- if (nm < 0.0052359877 && nm > 0.0034906585) {
2041
- irez = 1;
2042
- }
2043
- if (nm >= 8.26e-3 && nm <= 9.24e-3 && em >= 0.5) {
2044
- irez = 2;
2045
- }
2046
- // ------------------------ do solar terms -------------------
2047
- var ses = ss1 * zns * ss5;
2048
- var sis = ss2 * zns * (sz11 + sz13);
2049
- var sls = -zns * ss3 * (sz1 + sz3 - 14.0 - 6.0 * emsq);
2050
- var sghs = ss4 * zns * (sz31 + sz33 - 6.0);
2051
- var shs = -zns * ss2 * (sz21 + sz23);
2052
- // Sgp4fix for 180 deg incl
2053
- if (inclm < 5.2359877e-2 || inclm > PI - 5.2359877e-2) {
2054
- shs = 0.0;
2055
- }
2056
- if (sinim !== 0.0) {
2057
- shs /= sinim;
2058
- }
2059
- var sgs = sghs - cosim * shs;
2060
- // ------------------------- do lunar terms ------------------
2061
- dedt = ses + s1 * znl * s5;
2062
- didt = sis + s2 * znl * (z11 + z13);
2063
- dmdt = sls - znl * s3 * (z1 + z3 - 14.0 - 6.0 * emsq);
2064
- var sghl = s4 * znl * (z31 + z33 - 6.0);
2065
- var shll = -znl * s2 * (z21 + z23);
2066
- // Sgp4fix for 180 deg incl
2067
- if (inclm < 5.2359877e-2 || inclm > PI - 5.2359877e-2) {
2068
- shll = 0.0;
2069
- }
2070
- domdt = sgs + sghl;
2071
- dnodt = shs;
2072
- if (sinim !== 0.0) {
2073
- domdt -= (cosim / sinim) * shll;
2074
- dnodt += shll / sinim;
2075
- }
2076
- // ----------- calculate deep space resonance effects --------
2077
- var dndt = 0.0;
2078
- var theta = (gsto + tc * rptim) % TAU;
2079
- em += dedt * t;
2080
- inclm += didt * t;
2081
- argpm += domdt * t;
2082
- nodem += dnodt * t;
2083
- mm += dmdt * t;
2084
- /*
2085
- * Sgp4fix for negative inclinations
2086
- * the following if statement should be commented out
2087
- * if (inclm < 0.0)
2088
- * {
2089
- * inclm = -inclm;
2090
- * argpm = argpm - PI;
2091
- * nodem = nodem + PI;
2092
- * }
2093
- */
2094
- // -------------- initialize the resonance terms -------------
2095
- if (irez !== 0) {
2096
- var aonv = Math.pow((nm / xke), x2o3);
2097
- // ---------- geopotential resonance for 12 hour orbits ------
2098
- if (irez === 2) {
2099
- var cosisq = cosim * cosim;
2100
- var emo = em;
2101
- em = ecco;
2102
- var emsqo = emsq;
2103
- emsq = eccsq;
2104
- var eoc = em * emsq;
2105
- var g201 = -0.306 - (em - 0.64) * 0.44;
2106
- var g211 = void 0, g310 = void 0, g322 = void 0, g410 = void 0, g422 = void 0, g520 = void 0, g521 = void 0, g532 = void 0, g533 = void 0;
2107
- if (em <= 0.65) {
2108
- g211 = 3.616 - 13.247 * em + 16.29 * emsq;
2109
- g310 = -19.302 + 117.39 * em - 228.419 * emsq + 156.591 * eoc;
2110
- g322 = -18.9068 + 109.7927 * em - 214.6334 * emsq + 146.5816 * eoc;
2111
- g410 = -41.122 + 242.694 * em - 471.094 * emsq + 313.953 * eoc;
2112
- g422 = -146.407 + 841.88 * em - 1629.014 * emsq + 1083.435 * eoc;
2113
- g520 = -532.114 + 3017.977 * em - 5740.032 * emsq + 3708.276 * eoc;
2114
- }
2115
- else {
2116
- g211 = -72.099 + 331.819 * em - 508.738 * emsq + 266.724 * eoc;
2117
- g310 = -346.844 + 1582.851 * em - 2415.925 * emsq + 1246.113 * eoc;
2118
- g322 = -342.585 + 1554.908 * em - 2366.899 * emsq + 1215.972 * eoc;
2119
- g410 = -1052.797 + 4758.686 * em - 7193.992 * emsq + 3651.957 * eoc;
2120
- g422 = -3581.69 + 16178.11 * em - 24462.77 * emsq + 12422.52 * eoc;
2121
- if (em > 0.715) {
2122
- g520 = -5149.66 + 29936.92 * em - 54087.36 * emsq + 31324.56 * eoc;
2123
- }
2124
- else {
2125
- g520 = 1464.74 - 4664.75 * em + 3763.64 * emsq;
2126
- }
2127
- }
2128
- if (em < 0.7) {
2129
- g533 = -919.2277 + 4988.61 * em - 9064.77 * emsq + 5542.21 * eoc;
2130
- g521 = -822.71072 + 4568.6173 * em - 8491.4146 * emsq + 5337.524 * eoc;
2131
- g532 = -853.666 + 4690.25 * em - 8624.77 * emsq + 5341.4 * eoc;
2132
- }
2133
- else {
2134
- g533 = -37995.78 + 161616.52 * em - 229838.2 * emsq + 109377.94 * eoc;
2135
- g521 = -51752.104 + 218913.95 * em - 309468.16 * emsq + 146349.42 * eoc;
2136
- g532 = -40023.88 + 170470.89 * em - 242699.48 * emsq + 115605.82 * eoc;
2137
- }
2138
- var sini2 = sinim * sinim;
2139
- var f220 = 0.75 * (1.0 + 2.0 * cosim + cosisq);
2140
- var f221 = 1.5 * sini2;
2141
- var f321 = 1.875 * sinim * (1.0 - 2.0 * cosim - 3.0 * cosisq);
2142
- var f322 = -1.875 * sinim * (1.0 + 2.0 * cosim - 3.0 * cosisq);
2143
- var f441 = 35.0 * sini2 * f220;
2144
- var f442 = 39.375 * sini2 * sini2;
2145
- var f522 = 9.84375 *
2146
- sinim *
2147
- (sini2 * (1.0 - 2.0 * cosim - 5.0 * cosisq) + 0.33333333 * (-2.0 + 4.0 * cosim + 6.0 * cosisq));
2148
- var f523 = sinim *
2149
- (4.92187512 * sini2 * (-2.0 - 4.0 * cosim + 10.0 * cosisq) + 6.56250012 * (1.0 + 2.0 * cosim - 3.0 * cosisq));
2150
- var f542 = 29.53125 * sinim * (2.0 - 8.0 * cosim + cosisq * (-12.0 + 8.0 * cosim + 10.0 * cosisq));
2151
- var f543 = 29.53125 * sinim * (-2.0 - 8.0 * cosim + cosisq * (12.0 + 8.0 * cosim - 10.0 * cosisq));
2152
- var xno2 = nm * nm;
2153
- var ainv2 = aonv * aonv;
2154
- var temp1 = 3.0 * xno2 * ainv2;
2155
- var temp = temp1 * root22;
2156
- d2201 = temp * f220 * g201;
2157
- d2211 = temp * f221 * g211;
2158
- temp1 *= aonv;
2159
- temp = temp1 * root32;
2160
- d3210 = temp * f321 * g310;
2161
- d3222 = temp * f322 * g322;
2162
- temp1 *= aonv;
2163
- temp = 2.0 * temp1 * root44;
2164
- d4410 = temp * f441 * g410;
2165
- d4422 = temp * f442 * g422;
2166
- temp1 *= aonv;
2167
- temp = temp1 * root52;
2168
- d5220 = temp * f522 * g520;
2169
- d5232 = temp * f523 * g532;
2170
- temp = 2.0 * temp1 * root54;
2171
- d5421 = temp * f542 * g521;
2172
- d5433 = temp * f543 * g533;
2173
- xlamo = (mo + nodeo + nodeo - (theta + theta)) % TAU;
2174
- xfact = mdot + dmdt + 2.0 * (nodedot + dnodt - rptim) - no;
2175
- em = emo;
2176
- emsq = emsqo;
2177
- }
2178
- // ---------------- synchronous resonance terms --------------
2179
- if (irez === 1) {
2180
- var g200 = 1.0 + emsq * (-2.5 + 0.8125 * emsq);
2181
- var g310 = 1.0 + 2.0 * emsq;
2182
- var g300 = 1.0 + emsq * (-6.0 + 6.60937 * emsq);
2183
- var f220 = 0.75 * (1.0 + cosim) * (1.0 + cosim);
2184
- var f311 = 0.9375 * sinim * sinim * (1.0 + 3.0 * cosim) - 0.75 * (1.0 + cosim);
2185
- var f330 = 1.0 + cosim;
2186
- f330 *= 1.875 * f330 * f330;
2187
- del1 = 3.0 * nm * nm * aonv * aonv;
2188
- del2 = 2.0 * del1 * f220 * g200 * q22;
2189
- del3 = 3.0 * del1 * f330 * g300 * q33 * aonv;
2190
- del1 = del1 * f311 * g310 * q31 * aonv;
2191
- xlamo = (mo + nodeo + argpo - theta) % TAU;
2192
- xfact = mdot + xPIdot + dmdt + domdt + dnodt - (no + rptim);
2193
- }
2194
- // ------------ for sgp4, initialize the integrator ----------
2195
- xli = xlamo;
2196
- xni = no;
2197
- atime = 0.0;
2198
- nm = no + dndt;
2199
- }
2200
- return {
2201
- em: em,
2202
- argpm: argpm,
2203
- inclm: inclm,
2204
- mm: mm,
2205
- nm: nm,
2206
- nodem: nodem,
2207
- irez: irez,
2208
- atime: atime,
2209
- d2201: d2201,
2210
- d2211: d2211,
2211
- d3210: d3210,
2212
- d3222: d3222,
2213
- d4410: d4410,
2214
- d4422: d4422,
2215
- d5220: d5220,
2216
- d5232: d5232,
2217
- d5421: d5421,
2218
- d5433: d5433,
2219
- dedt: dedt,
2220
- didt: didt,
2221
- dmdt: dmdt,
2222
- dndt: dndt,
2223
- dnodt: dnodt,
2224
- domdt: domdt,
2225
- del1: del1,
2226
- del2: del2,
2227
- del3: del3,
2228
- xfact: xfact,
2229
- xlamo: xlamo,
2230
- xli: xli,
2231
- xni: xni,
2232
- };
2233
- };
2234
- // Dsinit
2235
- /*
2236
- *-----------------------------------------------------------------------------
2237
- *
2238
- * procedure dspace
2239
- *
2240
- * this procedure provides deep space contributions to mean elements for
2241
- * perturbing third body. these effects have been averaged over one
2242
- * revolution of the sun and moon. for earth resonance effects, the
2243
- * effects have been averaged over no revolutions of the satellite.
2244
- * (mean motion)
2245
- *
2246
- * author : david vallado 719-573-2600 28 jun 2005
2247
- *
2248
- * inputs :
2249
- * d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433 -
2250
- * dedt -
2251
- * del1, del2, del3 -
2252
- * didt -
2253
- * dmdt -
2254
- * dnodt -
2255
- * domdt -
2256
- * irez - flag for resonance 0-none, 1-one day, 2-half day
2257
- * argpo - argument of perigee
2258
- * argpdot - argument of perigee dot (rate)
2259
- * t - time
2260
- * tc -
2261
- * gsto - gst
2262
- * xfact -
2263
- * xlamo -
2264
- * no - mean motion
2265
- * atime -
2266
- * em - eccentricity
2267
- * ft -
2268
- * argpm - argument of perigee
2269
- * inclm - inclination
2270
- * xli -
2271
- * mm - mean anomaly
2272
- * xni - mean motion
2273
- * nodem - right ascension of ascending node
2274
- *
2275
- * outputs :
2276
- * atime -
2277
- * em - eccentricity
2278
- * argpm - argument of perigee
2279
- * inclm - inclination
2280
- * xli -
2281
- * mm - mean anomaly
2282
- * xni -
2283
- * nodem - right ascension of ascending node
2284
- * dndt -
2285
- * nm - mean motion
2286
- *
2287
- * locals :
2288
- * delt -
2289
- * ft -
2290
- * theta -
2291
- * x2li -
2292
- * x2omi -
2293
- * xl -
2294
- * xldot -
2295
- * xnddt -
2296
- * xndt -
2297
- * xomi -
2298
- *
2299
- * coupling :
2300
- * none -
2301
- *
2302
- * references :
2303
- * hoots, roehrich, norad spacetrack report #3 1980
2304
- * hoots, norad spacetrack report #6 1986
2305
- * hoots, schumacher and glover 2004
2306
- * vallado, crawford, hujsak, kelso 2006
2307
- *----------------------------------------------------------------------------
2308
- */
2309
- Sgp4.dspace_ = function (irez, d2201, d2211, d3210, d3222, d4410, d4422, d5220, d5232, d5421, d5433, dedt, del1, del2, del3, didt, dmdt, dnodt, domdt, argpo, argpdot, t, tc, gsto, xfact, xlamo, no, atime, em, argpm, inclm, xli, mm, xni, nodem, nm) {
2310
- /** Ootk -- Some variables imported from outside the class at the top */
2311
- var fasx2 = 0.13130908;
2312
- var fasx4 = 2.8843198;
2313
- var fasx6 = 0.37448087;
2314
- var g22 = 5.7686396;
2315
- var g32 = 0.95240898;
2316
- var g44 = 1.8014998;
2317
- var g52 = 1.050833;
2318
- var g54 = 4.4108898;
2319
- // IDEA: Any way to fix this?
2320
- // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
2321
- var rptim = 4.37526908801129966e-3; // Equates to 7.29211514668855e-5 rad/sec
2322
- var stepp = 720.0;
2323
- var stepn = -720.0;
2324
- var step2 = 259200.0;
2325
- // ----------- calculate deep space resonance effects -----------
2326
- var dndt = 0.0;
2327
- var theta = (gsto + tc * rptim) % TAU;
2328
- em += dedt * t;
2329
- inclm += didt * t;
2330
- argpm += domdt * t;
2331
- nodem += dnodt * t;
2332
- mm += dmdt * t;
2333
- /*
2334
- * Sgp4fix for negative inclinations
2335
- * the following if statement should be commented out
2336
- * if (inclm < 0.0)
2337
- * {
2338
- * inclm = -inclm;
2339
- * argpm = argpm - PI;
2340
- * nodem = nodem + PI;
2341
- * }
2342
- */
2343
- /* - update resonances : numerical (euler-maclaurin) integration - */
2344
- /* ------------------------- epoch restart ---------------------- */
2345
- /*
2346
- * Sgp4fix for propagator problems
2347
- * the following integration works for negative time steps and periods
2348
- * the specific changes are unknown because the original code was so convoluted
2349
- */
2350
- // Sgp4fix take out atime = 0.0 and fix for faster operation
2351
- // Ft = 0.0; /** Ootk -- This has no value */
2352
- if (irez !== 0) {
2353
- // Sgp4fix streamline check
2354
- if (atime === 0.0 || t * atime <= 0.0 || Math.abs(t) < Math.abs(atime)) {
2355
- atime = 0.0;
2356
- xni = no;
2357
- xli = xlamo;
2358
- }
2359
- // Sgp4fix move check outside loop
2360
- var delt = void 0;
2361
- if (t > 0.0) {
2362
- delt = stepp;
2363
- }
2364
- else {
2365
- delt = stepn;
2366
- }
2367
- var ft = void 0, x2li = void 0, x2omi = void 0, xldot = void 0, xnddt = void 0, xndt = void 0, xomi = void 0;
2368
- var iretn = 381; // Added for do loop
2369
- while (iretn === 381) {
2370
- /*
2371
- * ------------------- dot terms calculated -------------
2372
- * ----------- near - synchronous resonance terms -------
2373
- */
2374
- if (irez !== 2) {
2375
- xndt =
2376
- del1 * Math.sin(xli - fasx2) + del2 * Math.sin(2.0 * (xli - fasx4)) + del3 * Math.sin(3.0 * (xli - fasx6));
2377
- xldot = xni + xfact;
2378
- xnddt =
2379
- del1 * Math.cos(xli - fasx2) +
2380
- 2.0 * del2 * Math.cos(2.0 * (xli - fasx4)) +
2381
- 3.0 * del3 * Math.cos(3.0 * (xli - fasx6));
2382
- xnddt *= xldot;
2383
- }
2384
- else {
2385
- // --------- near - half-day resonance terms --------
2386
- xomi = argpo + argpdot * atime;
2387
- x2omi = xomi + xomi;
2388
- x2li = xli + xli;
2389
- xndt =
2390
- d2201 * Math.sin(x2omi + xli - g22) +
2391
- d2211 * Math.sin(xli - g22) +
2392
- d3210 * Math.sin(xomi + xli - g32) +
2393
- d3222 * Math.sin(-xomi + xli - g32) +
2394
- d4410 * Math.sin(x2omi + x2li - g44) +
2395
- d4422 * Math.sin(x2li - g44) +
2396
- d5220 * Math.sin(xomi + xli - g52) +
2397
- d5232 * Math.sin(-xomi + xli - g52) +
2398
- d5421 * Math.sin(xomi + x2li - g54) +
2399
- d5433 * Math.sin(-xomi + x2li - g54);
2400
- xldot = xni + xfact;
2401
- xnddt =
2402
- d2201 * Math.cos(x2omi + xli - g22) +
2403
- d2211 * Math.cos(xli - g22) +
2404
- d3210 * Math.cos(xomi + xli - g32) +
2405
- d3222 * Math.cos(-xomi + xli - g32) +
2406
- d5220 * Math.cos(xomi + xli - g52) +
2407
- d5232 * Math.cos(-xomi + xli - g52) +
2408
- 2.0 *
2409
- (d4410 * Math.cos(x2omi + x2li - g44) +
2410
- d4422 * Math.cos(x2li - g44) +
2411
- d5421 * Math.cos(xomi + x2li - g54) +
2412
- d5433 * Math.cos(-xomi + x2li - g54));
2413
- xnddt *= xldot;
2414
- }
2415
- /*
2416
- * ----------------------- integrator -------------------
2417
- * sgp4fix move end checks to end of routine
2418
- */
2419
- if (Math.abs(t - atime) >= stepp) {
2420
- // Iret = 0; /** Ootk -- This has no value */
2421
- iretn = 381;
2422
- }
2423
- else {
2424
- ft = t - atime;
2425
- iretn = 0;
2426
- }
2427
- if (iretn === 381) {
2428
- xli += xldot * delt + xndt * step2;
2429
- xni += xndt * delt + xnddt * step2;
2430
- atime += delt;
2431
- }
2432
- } // While iretn = 381
2433
- nm = xni + xndt * ft + xnddt * ft * ft * 0.5;
2434
- var xl = xli + xldot * ft + xndt * ft * ft * 0.5;
2435
- if (irez !== 1) {
2436
- mm = xl - 2.0 * nodem + 2.0 * theta;
2437
- dndt = nm - no;
2438
- }
2439
- else {
2440
- mm = xl - nodem - argpm + theta;
2441
- dndt = nm - no;
2442
- }
2443
- nm = no + dndt;
2444
- }
2445
- return [em, argpm, inclm, mm, nodem, nm];
2446
- };
2447
- /*
2448
- * -----------------------------------------------------------------------------
2449
- *
2450
- * function getgravconst
2451
- *
2452
- * this function gets constants for the propagator. note that mu is identified to
2453
- * facilitiate comparisons with newer models. the common useage is wgs72.
2454
- *
2455
- * author : david vallado 719-573-2600 21 jul 2006
2456
- *
2457
- * inputs :
2458
- * whichconst - which set of constants to use wgs72old, wgs72, wgs84
2459
- *
2460
- * outputs :
2461
- * tumin - minutes in one time unit
2462
- * mu - earth gravitational parameter
2463
- * radiusearthkm - radius of the earth in km
2464
- * xke - reciprocal of tumin
2465
- * j2, j3, j4 - un-normalized zonal harmonic values
2466
- * j3oj2 - j3 divided by j2
2467
- *
2468
- * locals :
2469
- *
2470
- * coupling :
2471
- * none
2472
- *
2473
- * references :
2474
- * norad spacetrack report #3
2475
- * vallado, crawford, hujsak, kelso 2006
2476
- * ---------------------------------------------------------------------------
2477
- */
2478
- Sgp4.getgravconst_ = function (whichconst) {
2479
- var j2, j3, j3oj2, j4, mus, radiusearthkm, tumin, xke;
2480
- switch (whichconst) {
2481
- // -- wgs-72 low precision str#3 constants --
2482
- case 'wgs72old':
2483
- mus = 398600.79964; // In km3 / s2
2484
- radiusearthkm = 6378.135; // Km
2485
- xke = 0.0743669161; // Reciprocal of tumin
2486
- tumin = 1.0 / xke;
2487
- j2 = 0.001082616;
2488
- j3 = -0.00000253881;
2489
- j4 = -0.00000165597;
2490
- j3oj2 = j3 / j2;
2491
- break;
2492
- // ------------ wgs-72 constants ------------
2493
- case 'wgs72':
2494
- mus = 398600.8; // In km3 / s2
2495
- radiusearthkm = 6378.135; // Km
2496
- xke = 60.0 / Math.sqrt((radiusearthkm * radiusearthkm * radiusearthkm) / mus);
2497
- tumin = 1.0 / xke;
2498
- j2 = 0.001082616;
2499
- j3 = -0.00000253881;
2500
- j4 = -0.00000165597;
2501
- j3oj2 = j3 / j2;
2502
- break;
2503
- case 'wgs84':
2504
- // ------------ wgs-84 constants ------------
2505
- mus = 398600.5; // In km3 / s2
2506
- radiusearthkm = 6378.137; // Km
2507
- xke = 60.0 / Math.sqrt((radiusearthkm * radiusearthkm * radiusearthkm) / mus);
2508
- tumin = 1.0 / xke;
2509
- j2 = 0.00108262998905;
2510
- j3 = -0.00000253215306;
2511
- j4 = -0.00000161098761;
2512
- j3oj2 = j3 / j2;
2513
- break;
2514
- default:
2515
- throw new Error("unknown gravity option ".concat(whichconst));
2516
- }
2517
- return {
2518
- tumin: tumin,
2519
- mus: mus,
2520
- radiusearthkm: radiusearthkm,
2521
- xke: xke,
2522
- j2: j2,
2523
- j3: j3,
2524
- j4: j4,
2525
- j3oj2: j3oj2,
2526
- };
2527
- };
2528
- // Dspace
2529
- /*
2530
- *-----------------------------------------------------------------------------
2531
- *
2532
- * procedure initl
2533
- *
2534
- * this procedure initializes the sgp4 propagator. all the initialization is
2535
- * consolidated here instead of having multiple loops inside other routines.
2536
- *
2537
- * author : david vallado 719-573-2600 28 jun 2005
2538
- *
2539
- * inputs :
2540
- * satn - satellite number - not needed, placed in satrec
2541
- * xke - reciprocal of tumin
2542
- * j2 - j2 zonal harmonic
2543
- * ecco - eccentricity 0.0 - 1.0
2544
- * epoch - epoch time in days from jan 0, 1950. 0 hr
2545
- * inclo - inclination of satellite
2546
- * no - mean motion of satellite
2547
- *
2548
- * outputs :
2549
- * ainv - 1.0 / a
2550
- * ao - semi major axis
2551
- * con41 -
2552
- * con42 - 1.0 - 5.0 cos(i)
2553
- * cosio - cosine of inclination
2554
- * cosio2 - cosio squared
2555
- * eccsq - eccentricity squared
2556
- * method - flag for deep space 'd', 'n'
2557
- * omeosq - 1.0 - ecco * ecco
2558
- * posq - semi-parameter squared
2559
- * rp - radius of perigee
2560
- * rteosq - square root of (1.0 - ecco*ecco)
2561
- * sinio - sine of inclination
2562
- * gsto - gst at time of observation rad
2563
- * no - mean motion of satellite
2564
- *
2565
- * locals :
2566
- * ak -
2567
- * d1 -
2568
- * del -
2569
- * adel -
2570
- * po -
2571
- *
2572
- * coupling :
2573
- * getgravconst- no longer used
2574
- * gstime - find greenwich sidereal time from the julian date
2575
- *
2576
- * references :
2577
- * hoots, roehrich, norad spacetrack report #3 1980
2578
- * hoots, norad spacetrack report #6 1986
2579
- * hoots, schumacher and glover 2004
2580
- * vallado, crawford, hujsak, kelso 2006
2581
- *----------------------------------------------------------------------------
2582
- */
2583
- Sgp4.initl_ = function (options) {
2584
- /*
2585
- * Sgp4fix satn not needed. include in satrec in case needed later
2586
- * int satn,
2587
- * sgp4fix just pass in xke and j2
2588
- * gravconsttype whichconst,
2589
- */
2590
- var opsmode = options.opsmode, ecco = options.ecco, epoch = options.epoch, inclo = options.inclo, xke = options.xke, j2 = options.j2;
2591
- var no = options.no;
2592
- /* --------------------- local variables ------------------------ */
2593
- var PI = Math.PI;
2594
- var TAU = PI * 2;
2595
- var x2o3 = 2.0 / 3.0;
2596
- // Sgp4fix use old way of finding gst
2597
- /** Ootk -- Some variables imported from outside the class at the top */
2598
- /*
2599
- * ----------------------- earth constants ---------------------
2600
- * sgp4fix identify constants and allow alternate values
2601
- * only xke and j2 are used here so pass them in directly
2602
- * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 )
2603
- */
2604
- // ------------- calculate auxillary epoch quantities ----------
2605
- var eccsq = ecco * ecco;
2606
- var omeosq = 1.0 - eccsq;
2607
- var rteosq = Math.sqrt(omeosq);
2608
- var cosio = Math.cos(inclo);
2609
- var cosio2 = cosio * cosio;
2610
- // ------------------ un-kozai the mean motion -----------------
2611
- var ak = Math.pow((xke / no), x2o3);
2612
- var d1 = (0.75 * j2 * (3.0 * cosio2 - 1.0)) / (rteosq * omeosq);
2613
- var delPrime = d1 / (ak * ak);
2614
- var adel = ak * (1.0 - delPrime * delPrime - delPrime * (1.0 / 3.0 + (134.0 * delPrime * delPrime) / 81.0));
2615
- delPrime = d1 / (adel * adel);
2616
- no /= 1.0 + delPrime;
2617
- var ao = Math.pow((xke / no), x2o3);
2618
- var sinio = Math.sin(inclo);
2619
- var po = ao * omeosq;
2620
- var con42 = 1.0 - 5.0 * cosio2;
2621
- var con41 = -con42 - cosio2 - cosio2;
2622
- var ainv = 1.0 / ao;
2623
- var posq = po * po;
2624
- var rp = ao * (1.0 - ecco);
2625
- var method = 'n';
2626
- // Sgp4fix modern approach to finding sidereal time
2627
- /** Ootk -- Continue allowing AFSPC mode for SGP4 Validation */
2628
- var gsto;
2629
- if (opsmode === 'a') {
2630
- /*
2631
- * Sgp4fix use old way of finding gst
2632
- * count integer number of days from 0 jan 1970
2633
- */
2634
- var ts70 = epoch - 7305.0;
2635
- var ds70 = Math.floor(ts70 + 1.0e-8);
2636
- var tfrac = ts70 - ds70;
2637
- // Find greenwich location at epoch
2638
- // IDEA: Precision issues in JavaScript...
2639
- // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
2640
- var c1 = 1.72027916940703639e-2;
2641
- // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
2642
- var thgr70 = 1.7321343856509374;
2643
- // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
2644
- var fk5r = 5.07551419432269442e-15;
2645
- var c1p2p = c1 + TAU;
2646
- gsto = (thgr70 + c1 * ds70 + c1p2p * tfrac + ts70 * ts70 * fk5r) % TAU;
2647
- /* istanbul ignore next | This is no longer possible*/
2648
- if (gsto < 0.0) {
2649
- gsto += TAU;
2650
- }
2651
- }
2652
- else {
2653
- gsto = Sgp4.gstime(epoch + 2433281.5);
2654
- }
2655
- return {
2656
- no: no,
2657
- method: method,
2658
- ainv: ainv,
2659
- ao: ao,
2660
- con41: con41,
2661
- con42: con42,
2662
- cosio: cosio,
2663
- cosio2: cosio2,
2664
- eccsq: eccsq,
2665
- omeosq: omeosq,
2666
- posq: posq,
2667
- rp: rp,
2668
- rteosq: rteosq,
2669
- sinio: sinio,
2670
- gsto: gsto,
2671
- };
2672
- };
2673
- // Initl
2674
- /*
2675
- *-----------------------------------------------------------------------------
2676
- *
2677
- * procedure sgp4init
2678
- *
2679
- * this procedure initializes variables for sgp4.
2680
- *
2681
- * author : david vallado 719-573-2600 28 jun 2005
2682
- *
2683
- * inputs :
2684
- * opsmode - mode of operation afspc or improved 'a', 'i'
2685
- * whichconst - which set of constants to use 72, 84
2686
- * satn - satellite number
2687
- * bstar - sgp4 type drag coefficient kg/m2er
2688
- * ecco - eccentricity
2689
- * epoch - epoch time in days from jan 0, 1950. 0 hr
2690
- * argpo - argument of perigee (output if ds)
2691
- * inclo - inclination
2692
- * mo - mean anomaly (output if ds)
2693
- * no - mean motion
2694
- * nodeo - right ascension of ascending node
2695
- *
2696
- * outputs :
2697
- * rec - common values for subsequent calls
2698
- * return code - non-zero on error.
2699
- * 1 - mean elements, ecc >= 1.0 or ecc < -0.001 or a < 0.95 er
2700
- * 2 - mean motion less than 0.0
2701
- * 3 - pert elements, ecc < 0.0 or ecc > 1.0
2702
- * 4 - semi-latus rectum < 0.0
2703
- * 5 - epoch elements are sub-orbital
2704
- * 6 - satellite has decayed
2705
- *
2706
- * locals :
2707
- * cnodm , snodm , cosim , sinim , cosomm , sinomm
2708
- * cc1sq , cc2 , cc3
2709
- * coef , coef1
2710
- * cosio4 -
2711
- * day -
2712
- * dndt -
2713
- * em - eccentricity
2714
- * emsq - eccentricity squared
2715
- * eeta -
2716
- * etasq -
2717
- * gam -
2718
- * argpm - argument of perigee
2719
- * nodem -
2720
- * inclm - inclination
2721
- * mm - mean anomaly
2722
- * nm - mean motion
2723
- * perige - perigee
2724
- * PInvsq -
2725
- * psisq -
2726
- * qzms24 -
2727
- * rtemsq -
2728
- * s1, s2, s3, s4, s5, s6, s7 -
2729
- * sfour -
2730
- * ss1, ss2, ss3, ss4, ss5, ss6, ss7 -
2731
- * sz1, sz2, sz3
2732
- * sz11, sz12, sz13, sz21, sz22, sz23, sz31, sz32, sz33 -
2733
- * tc -
2734
- * temp -
2735
- * temp1, temp2, temp3 -
2736
- * tsi -
2737
- * xPIdot -
2738
- * xhdot1 -
2739
- * z1, z2, z3 -
2740
- * z11, z12, z13, z21, z22, z23, z31, z32, z33 -
2741
- *
2742
- * coupling :
2743
- * getgravconst-
2744
- * initl -
2745
- * dscom -
2746
- * dpper -
2747
- * dsinit -
2748
- * sgp4 -
2749
- *
2750
- * references :
2751
- * hoots, roehrich, norad spacetrack report #3 1980
2752
- * hoots, norad spacetrack report #6 1986
2753
- * hoots, schumacher and glover 2004
2754
- * vallado, crawford, hujsak, kelso 2006
2755
- *----------------------------------------------------------------------------
2756
- */
2757
- Sgp4.sgp4init_ = function (satrec, options) {
2758
- /* eslint-disable no-param-reassign */
2759
- var _a = options.whichconst, whichconst = _a === void 0 ? 'wgs72' : _a, _b = options.opsmode, opsmode = _b === void 0 ? 'i' : _b, _c = options.satn, satn = _c === void 0 ? satrec.satnum : _c, epoch = options.epoch, xbstar = options.xbstar, xecco = options.xecco, xargpo = options.xargpo, xinclo = options.xinclo, xndot = options.xndot, xnddot = options.xnddot, xmo = options.xmo, xno = options.xno, xnodeo = options.xnodeo;
2760
- /* ------------------------ initialization --------------------- */
2761
- /*
2762
- * Sgp4fix divisor for divide by zero check on inclination
2763
- * the old check used 1.0 + Math.cos(PI-1.0e-9), but then compared it to
2764
- * 1.5 e-12, so the threshold was changed to 1.5e-12 for consistency
2765
- */
2766
- // ----------- set all near earth variables to zero ------------
2767
- satrec.isimp = 0;
2768
- satrec.method = 'n';
2769
- satrec.aycof = 0.0;
2770
- satrec.con41 = 0.0;
2771
- satrec.cc1 = 0.0;
2772
- satrec.cc4 = 0.0;
2773
- satrec.cc5 = 0.0;
2774
- satrec.d2 = 0.0;
2775
- satrec.d3 = 0.0;
2776
- satrec.d4 = 0.0;
2777
- satrec.delmo = 0.0;
2778
- satrec.eta = 0.0;
2779
- satrec.argpdot = 0.0;
2780
- satrec.omgcof = 0.0;
2781
- satrec.sinmao = 0.0;
2782
- satrec.t = 0.0;
2783
- satrec.t2cof = 0.0;
2784
- satrec.t3cof = 0.0;
2785
- satrec.t4cof = 0.0;
2786
- satrec.t5cof = 0.0;
2787
- satrec.x1mth2 = 0.0;
2788
- satrec.x7thm1 = 0.0;
2789
- satrec.mdot = 0.0;
2790
- satrec.nodedot = 0.0;
2791
- satrec.xlcof = 0.0;
2792
- satrec.xmcof = 0.0;
2793
- satrec.nodecf = 0.0;
2794
- // ----------- set all deep space variables to zero ------------
2795
- satrec.irez = 0;
2796
- satrec.d2201 = 0.0;
2797
- satrec.d2211 = 0.0;
2798
- satrec.d3210 = 0.0;
2799
- satrec.d3222 = 0.0;
2800
- satrec.d4410 = 0.0;
2801
- satrec.d4422 = 0.0;
2802
- satrec.d5220 = 0.0;
2803
- satrec.d5232 = 0.0;
2804
- satrec.d5421 = 0.0;
2805
- satrec.d5433 = 0.0;
2806
- satrec.dedt = 0.0;
2807
- satrec.del1 = 0.0;
2808
- satrec.del2 = 0.0;
2809
- satrec.del3 = 0.0;
2810
- satrec.didt = 0.0;
2811
- satrec.dmdt = 0.0;
2812
- satrec.dnodt = 0.0;
2813
- satrec.domdt = 0.0;
2814
- satrec.e3 = 0.0;
2815
- satrec.ee2 = 0.0;
2816
- satrec.peo = 0.0;
2817
- satrec.pgho = 0.0;
2818
- satrec.pho = 0.0;
2819
- satrec.PInco = 0.0;
2820
- satrec.plo = 0.0;
2821
- satrec.se2 = 0.0;
2822
- satrec.se3 = 0.0;
2823
- satrec.sgh2 = 0.0;
2824
- satrec.sgh3 = 0.0;
2825
- satrec.sgh4 = 0.0;
2826
- satrec.sh2 = 0.0;
2827
- satrec.sh3 = 0.0;
2828
- satrec.si2 = 0.0;
2829
- satrec.si3 = 0.0;
2830
- satrec.sl2 = 0.0;
2831
- satrec.sl3 = 0.0;
2832
- satrec.sl4 = 0.0;
2833
- satrec.gsto = 0.0;
2834
- satrec.xfact = 0.0;
2835
- satrec.xgh2 = 0.0;
2836
- satrec.xgh3 = 0.0;
2837
- satrec.xgh4 = 0.0;
2838
- satrec.xh2 = 0.0;
2839
- satrec.xh3 = 0.0;
2840
- satrec.xi2 = 0.0;
2841
- satrec.xi3 = 0.0;
2842
- satrec.xl2 = 0.0;
2843
- satrec.xl3 = 0.0;
2844
- satrec.xl4 = 0.0;
2845
- satrec.xlamo = 0.0;
2846
- satrec.zmol = 0.0;
2847
- satrec.zmos = 0.0;
2848
- satrec.atime = 0.0;
2849
- satrec.xli = 0.0;
2850
- satrec.xni = 0.0;
2851
- /* ------------------------ earth constants ----------------------- */
2852
- /*
2853
- * Sgp4fix identify constants and allow alternate values
2854
- * this is now the only call for the constants
2855
- */
2856
- var gravResults = Sgp4.getgravconst_(whichconst);
2857
- satrec.tumin = gravResults.tumin;
2858
- satrec.mus = gravResults.mus;
2859
- satrec.radiusearthkm = gravResults.radiusearthkm;
2860
- satrec.xke = gravResults.xke;
2861
- satrec.j2 = gravResults.j2;
2862
- satrec.j3 = gravResults.j3;
2863
- satrec.j4 = gravResults.j4;
2864
- satrec.j3oj2 = gravResults.j3oj2;
2865
- var j2 = gravResults.j2;
2866
- var j4 = gravResults.j4;
2867
- var xke = gravResults.xke;
2868
- var j3oj2 = gravResults.j3oj2;
2869
- // -------------------------------------------------------------------------
2870
- satrec.error = 0;
2871
- satrec.operationmode = opsmode;
2872
- // New alpha5 or 9-digit number
2873
- /**
2874
- * Ootk -- Using JS code for string manipulation but same effect
2875
- * Ex. A2525 = 102525
2876
- * Ex. Z1234 = 351234
2877
- */
2878
- var leadingChar = satn.split('')[0].toLowerCase(); // Using uppercase will break the -96 math.
2879
- if (isNaN(parseInt(leadingChar))) {
2880
- satrec.satnum = parseInt(leadingChar.charCodeAt(0) - 96 + 9 + satrec.satnum.slice(1, 5)).toString();
2881
- }
2882
- else {
2883
- satrec.satnum = satn;
2884
- }
2885
- /*
2886
- * Sgp4fix - note the following variables are also passed directly via satrec.
2887
- * it is possible to streamline the sgp4init call by deleting the "x"
2888
- * variables, but the user would need to set the satrec.* values first. we
2889
- * include the additional assignments in case twoline2rv is not used.
2890
- */
2891
- satrec.bstar = xbstar;
2892
- // Sgp4fix allow additional parameters in the struct
2893
- satrec.ndot = xndot;
2894
- satrec.nddot = xnddot;
2895
- satrec.ecco = xecco;
2896
- satrec.argpo = xargpo;
2897
- satrec.inclo = xinclo;
2898
- satrec.mo = xmo;
2899
- // Sgp4fix rename variables to clarify which mean motion is intended
2900
- satrec.no = xno;
2901
- satrec.nodeo = xnodeo;
2902
- /*
2903
- * Single averaged mean elements
2904
- * satrec.am = satrec.em = satrec.im = satrec.Om = satrec.mm = satrec.nm = 0.0;
2905
- */
2906
- /*
2907
- * ------------------------ earth constants -----------------------
2908
- * sgp4fix identify constants and allow alternate values
2909
- * getgravconst( whichconst, tumin, mu, radiusearthkm, xke, j2, j3, j4, j3oj2 );
2910
- */
2911
- var ss = 78.0 / satrec.radiusearthkm + 1.0;
2912
- // Sgp4fix use multiply for speed instead of pow
2913
- var qzms2ttemp = (120.0 - 78.0) / satrec.radiusearthkm;
2914
- var qzms2t = qzms2ttemp * qzms2ttemp * qzms2ttemp * qzms2ttemp;
2915
- satrec.init = 'y';
2916
- satrec.t = 0.0;
2917
- // Sgp4fix remove satn as it is not needed in initl
2918
- var initlOptions = {
2919
- ecco: satrec.ecco,
2920
- epoch: epoch,
2921
- inclo: satrec.inclo,
2922
- no: satrec.no,
2923
- method: satrec.method,
2924
- opsmode: satrec.operationmode,
2925
- xke: satrec.xke,
2926
- j2: satrec.j2,
2927
- };
2928
- var initlResult = Sgp4.initl_(initlOptions);
2929
- var ao = initlResult.ao, con42 = initlResult.con42, cosio = initlResult.cosio, cosio2 = initlResult.cosio2, eccsq = initlResult.eccsq, omeosq = initlResult.omeosq, posq = initlResult.posq, rp = initlResult.rp, rteosq = initlResult.rteosq, sinio = initlResult.sinio;
2930
- satrec.no = initlResult.no;
2931
- satrec.con41 = initlResult.con41;
2932
- satrec.gsto = initlResult.gsto;
2933
- satrec.a = Math.pow((satrec.no * satrec.tumin), (-2.0 / 3.0));
2934
- satrec.alta = satrec.a * (1.0 + satrec.ecco) - 1.0;
2935
- satrec.altp = satrec.a * (1.0 - satrec.ecco) - 1.0;
2936
- satrec.error = 0;
2937
- /*
2938
- * Sgp4fix remove this check as it is unnecessary
2939
- * the mrt check in sgp4 handles decaying satellite cases even if the starting
2940
- * condition is below the surface of te earth
2941
- * if (rp < 1.0)
2942
- * {
2943
- * printf("// *** satn%d epoch elts sub-orbital ***\n", satn);
2944
- * satrec.error = 5;
2945
- * }
2946
- */
2947
- if (omeosq >= 0.0 || satrec.no >= 0.0) {
2948
- satrec.isimp = 0;
2949
- if (rp < 220.0 / satrec.radiusearthkm + 1.0) {
2950
- satrec.isimp = 1;
2951
- }
2952
- var sfour = ss;
2953
- var qzms24 = qzms2t;
2954
- var perige = (rp - 1.0) * satrec.radiusearthkm;
2955
- // - for perigees below 156 km, s and qoms2t are altered -
2956
- if (perige < 156.0) {
2957
- sfour = perige - 78.0;
2958
- if (perige < 98.0) {
2959
- sfour = 20.0;
2960
- }
2961
- // Sgp4fix use multiply for speed instead of pow
2962
- var qzms24temp = (120.0 - sfour) / satrec.radiusearthkm;
2963
- qzms24 = qzms24temp * qzms24temp * qzms24temp * qzms24temp;
2964
- sfour = sfour / satrec.radiusearthkm + 1.0;
2965
- }
2966
- var PInvsq = 1.0 / posq;
2967
- var tsi = 1.0 / (ao - sfour);
2968
- satrec.eta = ao * satrec.ecco * tsi;
2969
- var etasq = satrec.eta * satrec.eta;
2970
- var eeta = satrec.ecco * satrec.eta;
2971
- var psisq = Math.abs(1.0 - etasq);
2972
- var coef = qzms24 * Math.pow(tsi, 4.0);
2973
- var coef1 = coef / Math.pow(psisq, 3.5);
2974
- var cc2 = coef1 *
2975
- satrec.no *
2976
- (ao * (1.0 + 1.5 * etasq + eeta * (4.0 + etasq)) +
2977
- ((0.375 * j2 * tsi) / psisq) * satrec.con41 * (8.0 + 3.0 * etasq * (8.0 + etasq)));
2978
- satrec.cc1 = satrec.bstar * cc2;
2979
- var cc3 = 0.0;
2980
- if (satrec.ecco > 1.0e-4) {
2981
- cc3 = (-2.0 * coef * tsi * j3oj2 * satrec.no * sinio) / satrec.ecco;
2982
- }
2983
- satrec.x1mth2 = 1.0 - cosio2;
2984
- satrec.cc4 =
2985
- 2.0 *
2986
- satrec.no *
2987
- coef1 *
2988
- ao *
2989
- omeosq *
2990
- (satrec.eta * (2.0 + 0.5 * etasq) +
2991
- satrec.ecco * (0.5 + 2.0 * etasq) -
2992
- ((j2 * tsi) / (ao * psisq)) *
2993
- (-3.0 * satrec.con41 * (1.0 - 2.0 * eeta + etasq * (1.5 - 0.5 * eeta)) +
2994
- 0.75 * satrec.x1mth2 * (2.0 * etasq - eeta * (1.0 + etasq)) * Math.cos(2.0 * satrec.argpo)));
2995
- satrec.cc5 = 2.0 * coef1 * ao * omeosq * (1.0 + 2.75 * (etasq + eeta) + eeta * etasq);
2996
- var cosio4 = cosio2 * cosio2;
2997
- var temp1 = 1.5 * j2 * PInvsq * satrec.no;
2998
- var temp2 = 0.5 * temp1 * j2 * PInvsq;
2999
- var temp3 = -0.46875 * j4 * PInvsq * PInvsq * satrec.no;
3000
- satrec.mdot =
3001
- satrec.no +
3002
- 0.5 * temp1 * rteosq * satrec.con41 +
3003
- 0.0625 * temp2 * rteosq * (13.0 - 78.0 * cosio2 + 137.0 * cosio4);
3004
- satrec.argpdot =
3005
- -0.5 * temp1 * con42 +
3006
- 0.0625 * temp2 * (7.0 - 114.0 * cosio2 + 395.0 * cosio4) +
3007
- temp3 * (3.0 - 36.0 * cosio2 + 49.0 * cosio4);
3008
- var xhdot1 = -temp1 * cosio;
3009
- satrec.nodedot = xhdot1 + (0.5 * temp2 * (4.0 - 19.0 * cosio2) + 2.0 * temp3 * (3.0 - 7.0 * cosio2)) * cosio;
3010
- var xPIdot = satrec.argpdot + satrec.nodedot;
3011
- satrec.omgcof = satrec.bstar * cc3 * Math.cos(satrec.argpo);
3012
- satrec.xmcof = 0.0;
3013
- if (satrec.ecco > 1.0e-4) {
3014
- satrec.xmcof = (-x2o3 * coef * satrec.bstar) / eeta;
3015
- }
3016
- satrec.nodecf = 3.5 * omeosq * xhdot1 * satrec.cc1;
3017
- satrec.t2cof = 1.5 * satrec.cc1;
3018
- // Sgp4fix for divide by zero with xinco = 180 deg
3019
- if (Math.abs(cosio + 1.0) > 1.5e-12) {
3020
- satrec.xlcof = (-0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio)) / (1.0 + cosio);
3021
- }
3022
- else {
3023
- satrec.xlcof = (-0.25 * j3oj2 * sinio * (3.0 + 5.0 * cosio)) / temp4;
3024
- }
3025
- satrec.aycof = -0.5 * j3oj2 * sinio;
3026
- // Sgp4fix use multiply for speed instead of pow
3027
- var delmotemp = 1.0 + satrec.eta * Math.cos(satrec.mo);
3028
- satrec.delmo = delmotemp * delmotemp * delmotemp;
3029
- satrec.sinmao = Math.sin(satrec.mo);
3030
- satrec.x7thm1 = 7.0 * cosio2 - 1.0;
3031
- // --------------- deep space initialization -------------
3032
- if (TAU / satrec.no >= 225.0) {
3033
- satrec.method = 'd';
3034
- satrec.isimp = 1;
3035
- var tc = 0.0;
3036
- var inclm = satrec.inclo;
3037
- var dscomOptions = {
3038
- epoch: epoch,
3039
- ep: satrec.ecco,
3040
- argpp: satrec.argpo,
3041
- tc: tc,
3042
- inclp: satrec.inclo,
3043
- nodep: satrec.nodeo,
3044
- np: satrec.no,
3045
- e3: satrec.e3,
3046
- ee2: satrec.ee2,
3047
- peo: satrec.peo,
3048
- pgho: satrec.pgho,
3049
- pho: satrec.pho,
3050
- PInco: satrec.PInco,
3051
- plo: satrec.plo,
3052
- se2: satrec.se2,
3053
- se3: satrec.se3,
3054
- sgh2: satrec.sgh2,
3055
- sgh3: satrec.sgh3,
3056
- sgh4: satrec.sgh4,
3057
- sh2: satrec.sh2,
3058
- sh3: satrec.sh3,
3059
- si2: satrec.si2,
3060
- si3: satrec.si3,
3061
- sl2: satrec.sl2,
3062
- sl3: satrec.sl3,
3063
- sl4: satrec.sl4,
3064
- xgh2: satrec.xgh2,
3065
- xgh3: satrec.xgh3,
3066
- xgh4: satrec.xgh4,
3067
- xh2: satrec.xh2,
3068
- xh3: satrec.xh3,
3069
- xi2: satrec.xi2,
3070
- xi3: satrec.xi3,
3071
- xl2: satrec.xl2,
3072
- xl3: satrec.xl3,
3073
- xl4: satrec.xl4,
3074
- zmol: satrec.zmol,
3075
- zmos: satrec.zmos,
3076
- };
3077
- var dscomResult = Sgp4.dscom_(dscomOptions);
3078
- satrec.e3 = dscomResult.e3;
3079
- satrec.ee2 = dscomResult.ee2;
3080
- satrec.peo = dscomResult.peo;
3081
- satrec.pgho = dscomResult.pgho;
3082
- satrec.pho = dscomResult.pho;
3083
- satrec.PInco = dscomResult.PInco;
3084
- satrec.plo = dscomResult.plo;
3085
- satrec.se2 = dscomResult.se2;
3086
- satrec.se3 = dscomResult.se3;
3087
- satrec.sgh2 = dscomResult.sgh2;
3088
- satrec.sgh3 = dscomResult.sgh3;
3089
- satrec.sgh4 = dscomResult.sgh4;
3090
- satrec.sh2 = dscomResult.sh2;
3091
- satrec.sh3 = dscomResult.sh3;
3092
- satrec.si2 = dscomResult.si2;
3093
- satrec.si3 = dscomResult.si3;
3094
- satrec.sl2 = dscomResult.sl2;
3095
- satrec.sl3 = dscomResult.sl3;
3096
- satrec.sl4 = dscomResult.sl4;
3097
- var sinim = dscomResult.sinim, cosim = dscomResult.cosim, em = dscomResult.em, emsq = dscomResult.emsq, s1 = dscomResult.s1, s2 = dscomResult.s2, s3 = dscomResult.s3, s4 = dscomResult.s4, s5 = dscomResult.s5, ss1 = dscomResult.ss1, ss2 = dscomResult.ss2, ss3 = dscomResult.ss3, ss4 = dscomResult.ss4, ss5 = dscomResult.ss5, sz1 = dscomResult.sz1, sz3 = dscomResult.sz3, sz11 = dscomResult.sz11, sz13 = dscomResult.sz13, sz21 = dscomResult.sz21, sz23 = dscomResult.sz23, sz31 = dscomResult.sz31, sz33 = dscomResult.sz33;
3098
- satrec.xgh2 = dscomResult.xgh2;
3099
- satrec.xgh3 = dscomResult.xgh3;
3100
- satrec.xgh4 = dscomResult.xgh4;
3101
- satrec.xh2 = dscomResult.xh2;
3102
- satrec.xh3 = dscomResult.xh3;
3103
- satrec.xi2 = dscomResult.xi2;
3104
- satrec.xi3 = dscomResult.xi3;
3105
- satrec.xl2 = dscomResult.xl2;
3106
- satrec.xl3 = dscomResult.xl3;
3107
- satrec.xl4 = dscomResult.xl4;
3108
- satrec.zmol = dscomResult.zmol;
3109
- satrec.zmos = dscomResult.zmos;
3110
- var nm = dscomResult.nm, z1 = dscomResult.z1, z3 = dscomResult.z3, z11 = dscomResult.z11, z13 = dscomResult.z13, z21 = dscomResult.z21, z23 = dscomResult.z23, z31 = dscomResult.z31, z33 = dscomResult.z33;
3111
- var dpperOptions = {
3112
- inclo: inclm,
3113
- init: satrec.init,
3114
- ep: satrec.ecco,
3115
- inclp: satrec.inclo,
3116
- nodep: satrec.nodeo,
3117
- argpp: satrec.argpo,
3118
- mp: satrec.mo,
3119
- opsmode: satrec.operationmode,
3120
- };
3121
- var dpperResult = Sgp4.dpper_(satrec, dpperOptions);
3122
- satrec.ecco = dpperResult.ep;
3123
- satrec.inclo = dpperResult.inclp;
3124
- satrec.nodeo = dpperResult.nodep;
3125
- satrec.argpo = dpperResult.argpp;
3126
- satrec.mo = dpperResult.mp;
3127
- var argpm = 0.0;
3128
- var nodem = 0.0;
3129
- var mm = 0.0;
3130
- var dsinitOptions = {
3131
- xke: xke,
3132
- cosim: cosim,
3133
- emsq: emsq,
3134
- argpo: satrec.argpo,
3135
- s1: s1,
3136
- s2: s2,
3137
- s3: s3,
3138
- s4: s4,
3139
- s5: s5,
3140
- sinim: sinim,
3141
- ss1: ss1,
3142
- ss2: ss2,
3143
- ss3: ss3,
3144
- ss4: ss4,
3145
- ss5: ss5,
3146
- sz1: sz1,
3147
- sz3: sz3,
3148
- sz11: sz11,
3149
- sz13: sz13,
3150
- sz21: sz21,
3151
- sz23: sz23,
3152
- sz31: sz31,
3153
- sz33: sz33,
3154
- t: satrec.t,
3155
- tc: tc,
3156
- gsto: satrec.gsto,
3157
- mo: satrec.mo,
3158
- mdot: satrec.mdot,
3159
- no: satrec.no,
3160
- nodeo: satrec.nodeo,
3161
- nodedot: satrec.nodedot,
3162
- xPIdot: xPIdot,
3163
- z1: z1,
3164
- z3: z3,
3165
- z11: z11,
3166
- z13: z13,
3167
- z21: z21,
3168
- z23: z23,
3169
- z31: z31,
3170
- z33: z33,
3171
- ecco: satrec.ecco,
3172
- eccsq: eccsq,
3173
- em: em,
3174
- argpm: argpm,
3175
- inclm: inclm,
3176
- mm: mm,
3177
- nm: nm,
3178
- nodem: nodem,
3179
- irez: satrec.irez,
3180
- atime: satrec.atime,
3181
- d2201: satrec.d2201,
3182
- d2211: satrec.d2211,
3183
- d3210: satrec.d3210,
3184
- d3222: satrec.d3222,
3185
- d4410: satrec.d4410,
3186
- d4422: satrec.d4422,
3187
- d5220: satrec.d5220,
3188
- d5232: satrec.d5232,
3189
- d5421: satrec.d5421,
3190
- d5433: satrec.d5433,
3191
- dedt: satrec.dedt,
3192
- didt: satrec.didt,
3193
- dmdt: satrec.dmdt,
3194
- dnodt: satrec.dnodt,
3195
- domdt: satrec.domdt,
3196
- del1: satrec.del1,
3197
- del2: satrec.del2,
3198
- del3: satrec.del3,
3199
- xfact: satrec.xfact,
3200
- xlamo: satrec.xlamo,
3201
- xli: satrec.xli,
3202
- xni: satrec.xni,
3203
- };
3204
- var dsinitResult = Sgp4.dsinit_(dsinitOptions);
3205
- satrec.irez = dsinitResult.irez;
3206
- satrec.atime = dsinitResult.atime;
3207
- satrec.d2201 = dsinitResult.d2201;
3208
- satrec.d2211 = dsinitResult.d2211;
3209
- satrec.d3210 = dsinitResult.d3210;
3210
- satrec.d3222 = dsinitResult.d3222;
3211
- satrec.d4410 = dsinitResult.d4410;
3212
- satrec.d4422 = dsinitResult.d4422;
3213
- satrec.d5220 = dsinitResult.d5220;
3214
- satrec.d5232 = dsinitResult.d5232;
3215
- satrec.d5421 = dsinitResult.d5421;
3216
- satrec.d5433 = dsinitResult.d5433;
3217
- satrec.dedt = dsinitResult.dedt;
3218
- satrec.didt = dsinitResult.didt;
3219
- satrec.dmdt = dsinitResult.dmdt;
3220
- satrec.dnodt = dsinitResult.dnodt;
3221
- satrec.domdt = dsinitResult.domdt;
3222
- satrec.del1 = dsinitResult.del1;
3223
- satrec.del2 = dsinitResult.del2;
3224
- satrec.del3 = dsinitResult.del3;
3225
- satrec.xfact = dsinitResult.xfact;
3226
- satrec.xlamo = dsinitResult.xlamo;
3227
- satrec.xli = dsinitResult.xli;
3228
- satrec.xni = dsinitResult.xni;
3229
- }
3230
- // ----------- set variables if not deep space -----------
3231
- if (satrec.isimp !== 1) {
3232
- var cc1sq = satrec.cc1 * satrec.cc1;
3233
- satrec.d2 = 4.0 * ao * tsi * cc1sq;
3234
- var temp = (satrec.d2 * tsi * satrec.cc1) / 3.0;
3235
- satrec.d3 = (17.0 * ao + sfour) * temp;
3236
- satrec.d4 = 0.5 * temp * ao * tsi * (221.0 * ao + 31.0 * sfour) * satrec.cc1;
3237
- satrec.t3cof = satrec.d2 + 2.0 * cc1sq;
3238
- satrec.t4cof = 0.25 * (3.0 * satrec.d3 + satrec.cc1 * (12.0 * satrec.d2 + 10.0 * cc1sq));
3239
- satrec.t5cof =
3240
- 0.2 *
3241
- (3.0 * satrec.d4 +
3242
- 12.0 * satrec.cc1 * satrec.d3 +
3243
- 6.0 * satrec.d2 * satrec.d2 +
3244
- 15.0 * cc1sq * (2.0 * satrec.d2 + cc1sq));
3245
- } // If omeosq = 0 ...
3246
- /* Finally propogate to zero epoch to initialize all others. */
3247
- /*
3248
- * Sgp4fix take out check to let satellites process until they are actually below earth surface
3249
- * if(satrec.error == 0)
3250
- */
3251
- }
3252
- Sgp4.propagate(satrec, 0);
3253
- satrec.init = 'n';
3254
- /*
3255
- * Sgp4fix return boolean. satrec.error contains any error codes
3256
- * return satrec; -- no reason to return anything in JS
3257
- */
3258
- };
3259
- return Sgp4;
3260
- }());
3261
- export { Sgp4 };
3262
- //# sourceMappingURL=sgp4.js.map