UNPKG

9.43 kBJavaScriptView Raw
1function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
3/**
4 * @copyright 2013 Sonia Keys
5 * @copyright 2016 commenthol
6 * @license MIT
7 * @module apsis
8 */
9/**
10 * Apsis: Chapter 50, Perigee and apogee of the Moon
11 */
12
13import base from './base';
14var sin = Math.sin,
15 cos = Math.cos;
16
17/**
18 * conversion factor from k to T, given in (50.3) p. 356
19 */
20
21var ck = 1 / 1325.55;
22var D2R = Math.PI / 180;
23
24// from http://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html
25export var EARTH_RADIUS = 6378.137; // km
26// from http://nssdc.gsfc.nasa.gov/planetary/factsheet/moonfact.html
27export var MOON_RADIUS = 1738.1; // km
28
29/**
30 * mean time of perigee or apogee
31 * (50.1) p. 355
32 */
33var mean = function mean(T) {
34 return base.horner(T, 2451534.6698, 27.55454989 / ck, -0.0006691, -0.000001098, 0.0000000052);
35};
36
37/**
38 * snap returns k at half h nearest year y.
39 */
40var snap = function snap(y, h) {
41 var k = (y - 1999.97) * 13.2555; // (50.2) p. 355
42 return Math.floor(k - h + 0.5) + h;
43};
44
45/**
46 * meanPerigee returns the jde of the mean perigee of the Moon nearest the given date.
47 *
48 * @param {Number} year - is a decimal year specifying a date.
49 * @return {Number} jde - Julian ephemeris day
50 */
51export function meanPerigee(year) {
52 return mean(snap(year, 0) * ck);
53}
54
55/**
56 * perigee returns the jde of perigee of the Moon nearest the given date.
57 *
58 * @param {Number} year - is a decimal year specifying a date.
59 * @return {Number} jde - Julian ephemeris day
60 */
61export function perigee(year) {
62 var l = new La(year, 0);
63 return mean(l.T) + l.perigeeCorr();
64}
65
66/**
67 * meanApogee returns the jde of the mean apogee of the Moon nearest the given date.
68 *
69 * @param {Number} year - is a decimal year specifying a date.
70 * @return {Number} jde - Julian ephemeris day
71 */
72export function meanApogee(year) {
73 // (year float64) float64
74 return mean(snap(year, 0.5) * ck);
75}
76
77/**
78 * apogee returns the jde of apogee of the Moon nearest the given date.
79 *
80 * @param {Number} year - is a decimal year specifying a date.
81 * @return {Number} jde - Julian ephemeris day
82 */
83export function apogee(year) {
84 var l = new La(year, 0.5);
85 return mean(l.T) + l.apogeeCorr();
86}
87
88/**
89 * apogeeParallax returns equatorial horizontal parallax of the Moon at the Apogee nearest the given date.
90 *
91 * @param {Number} year - is a decimal year specifying a date.
92 * @return {Number} equatorial horizontal parallax in radians
93 */
94export function apogeeParallax(year) {
95 return new La(year, 0.5).apogeeParallax();
96}
97
98/**
99 * perigeeParallax returns equatorial horizontal parallax of the Moon at the Apogee nearest the given date.
100 *
101 * @param {Number} year - is a decimal year specifying a date.
102 * @return {Number} equatorial horizontal parallax in radians
103 */
104export function perigeeParallax(year) {
105 return new La(year, 0).perigeeParallax();
106}
107
108/**
109 * Calculate the distance earth - moon (center to center) using the parallax angle in radians
110 *
111 * @param {Number} parallax - parallax angle in radians
112 * @return {Number} distance in `km`
113 */
114export function distance(parallax) {
115 return EARTH_RADIUS / sin(parallax);
116}
117
118var La = function () {
119 function La(y, h) {
120 _classCallCheck(this, La);
121
122 this.k = snap(y, h);
123 this.T = this.k * ck; // (50.3) p. 350
124 this.D = base.horner(this.T, 171.9179 * D2R, 335.9106046 * D2R / ck, -0.0100383 * D2R, -0.00001156 * D2R, 0.000000055 * D2R);
125 this.M = base.horner(this.T, 347.3477 * D2R, 27.1577721 * D2R / ck, -0.000813 * D2R, -0.000001 * D2R);
126 this.F = base.horner(this.T, 316.6109 * D2R, 364.5287911 * D2R / ck, -0.0125053 * D2R, -0.0000148 * D2R);
127 return this;
128 }
129
130 /**
131 * perigee correction
132 */
133
134
135 La.prototype.perigeeCorr = function perigeeCorr() {
136 var l = this;
137 return -1.6769 * sin(2 * l.D) + 0.4589 * sin(4 * l.D) + -0.1856 * sin(6 * l.D) + 0.0883 * sin(8 * l.D) + (-0.0773 + 0.00019 * l.T) * sin(2 * l.D - l.M) + (0.0502 - 0.00013 * l.T) * sin(l.M) + -0.046 * sin(10 * l.D) + (0.0422 - 0.00011 * l.T) * sin(4 * l.D - l.M) + -0.0256 * sin(6 * l.D - l.M) + 0.0253 * sin(12 * l.D) + 0.0237 * sin(l.D) + 0.0162 * sin(8 * l.D - l.M) + -0.0145 * sin(14 * l.D) + 0.0129 * sin(2 * l.F) + -0.0112 * sin(3 * l.D) + -0.0104 * sin(10 * l.D - l.M) + 0.0086 * sin(16 * l.D) + 0.0069 * sin(12 * l.D - l.M) + 0.0066 * sin(5 * l.D) + -0.0053 * sin(2 * (l.D + l.F)) + -0.0052 * sin(18 * l.D) + -0.0046 * sin(14 * l.D - l.M) + -0.0041 * sin(7 * l.D) + 0.004 * sin(2 * l.D + l.M) + 0.0032 * sin(20 * l.D) + -0.0032 * sin(l.D + l.M) + 0.0031 * sin(16 * l.D - l.M) + -0.0029 * sin(4 * l.D + l.M) + 0.0027 * sin(9 * l.D) + 0.0027 * sin(4 * l.D + 2 * l.F) + -0.0027 * sin(2 * (l.D - l.M)) + 0.0024 * sin(4 * l.D - 2 * l.M) + -0.0021 * sin(6 * l.D - 2 * l.M) + -0.0021 * sin(22 * l.D) + -0.0021 * sin(18 * l.D - l.M) + 0.0019 * sin(6 * l.D + l.M) + -0.0018 * sin(11 * l.D) + -0.0014 * sin(8 * l.D + l.M) + -0.0014 * sin(4 * l.D - 2 * l.F) + -0.0014 * sin(6 * l.D + 2 * l.F) + 0.0014 * sin(3 * l.D + l.M) + -0.0014 * sin(5 * l.D + l.M) + 0.0013 * sin(13 * l.D) + 0.0013 * sin(20 * l.D - l.M) + 0.0011 * sin(3 * l.D + 2 * l.M) + -0.0011 * sin(2 * (2 * l.D + l.F - l.M)) + -0.001 * sin(l.D + 2 * l.M) + -0.0009 * sin(22 * l.D - l.M) + -0.0008 * sin(4 * l.F) + 0.0008 * sin(6 * l.D - 2 * l.F) + 0.0008 * sin(2 * (l.D - l.F) + l.M) + 0.0007 * sin(2 * l.M) + 0.0007 * sin(2 * l.F - l.M) + 0.0007 * sin(2 * l.D + 4 * l.F) + -0.0006 * sin(2 * (l.F - l.M)) + -0.0006 * sin(2 * (l.D - l.F + l.M)) + 0.0006 * sin(24 * l.D) + 0.0005 * sin(4 * (l.D - l.F)) + 0.0005 * sin(2 * (l.D + l.M)) + -0.0004 * sin(l.D - l.M);
138 };
139
140 /**
141 * apogee correction
142 */
143
144
145 La.prototype.apogeeCorr = function apogeeCorr() {
146 var l = this;
147 return 0.4392 * sin(2 * l.D) + 0.0684 * sin(4 * l.D) + (0.0456 - 0.00011 * l.T) * sin(l.M) + (0.0426 - 0.00011 * l.T) * sin(2 * l.D - l.M) + 0.0212 * sin(2 * l.F) + -0.0189 * sin(l.D) + 0.0144 * sin(6 * l.D) + 0.0113 * sin(4 * l.D - l.M) + 0.0047 * sin(2 * (l.D + l.F)) + 0.0036 * sin(l.D + l.M) + 0.0035 * sin(8 * l.D) + 0.0034 * sin(6 * l.D - l.M) + -0.0034 * sin(2 * (l.D - l.F)) + 0.0022 * sin(2 * (l.D - l.M)) + -0.0017 * sin(3 * l.D) + 0.0013 * sin(4 * l.D + 2 * l.F) + 0.0011 * sin(8 * l.D - l.M) + 0.001 * sin(4 * l.D - 2 * l.M) + 0.0009 * sin(10 * l.D) + 0.0007 * sin(3 * l.D + l.M) + 0.0006 * sin(2 * l.M) + 0.0005 * sin(2 * l.D + l.M) + 0.0005 * sin(2 * (l.D + l.M)) + 0.0004 * sin(6 * l.D + 2 * l.F) + 0.0004 * sin(6 * l.D - 2 * l.M) + 0.0004 * sin(10 * l.D - l.M) + -0.0004 * sin(5 * l.D) + -0.0004 * sin(4 * l.D - 2 * l.F) + 0.0003 * sin(2 * l.F + l.M) + 0.0003 * sin(12 * l.D) + 0.0003 * sin(2 * l.D + 2 * l.F - l.M) + -0.0003 * sin(l.D - l.M);
148 };
149
150 /**
151 * apogee parallax
152 */
153
154
155 La.prototype.apogeeParallax = function apogeeParallax() {
156 var s = Math.PI / 180 / 3600;
157 var l = this;
158 return 3245.251 * s + -9.147 * s * cos(2 * l.D) + -0.841 * s * cos(l.D) + 0.697 * s * cos(2 * l.F) + (-0.656 * s + 0.0016 * s * l.T) * cos(l.M) + 0.355 * s * cos(4 * l.D) + 0.159 * s * cos(2 * l.D - l.M) + 0.127 * s * cos(l.D + l.M) + 0.065 * s * cos(4 * l.D - l.M) + 0.052 * s * cos(6 * l.D) + 0.043 * s * cos(2 * l.D + l.M) + 0.031 * s * cos(2 * (l.D + l.F)) + -0.023 * s * cos(2 * (l.D - l.F)) + 0.022 * s * cos(2 * (l.D - l.M)) + 0.019 * s * cos(2 * (l.D + l.M)) + -0.016 * s * cos(2 * l.M) + 0.014 * s * cos(6 * l.D - l.M) + 0.01 * s * cos(8 * l.D);
159 };
160
161 /**
162 * perigee parallax
163 */
164
165
166 La.prototype.perigeeParallax = function perigeeParallax() {
167 var s = Math.PI / 180 / 3600;
168 var l = this;
169 return 3629.215 * s + 63.224 * s * cos(2 * l.D) + -6.990 * s * cos(4 * l.D) + (2.834 * s - 0.0071 * l.T * s) * cos(2 * l.D - l.M) + 1.927 * s * cos(6 * l.D) + -1.263 * s * cos(l.D) + -0.702 * s * cos(8 * l.D) + (0.696 * s - 0.0017 * l.T * s) * cos(l.M) + -0.690 * s * cos(2 * l.F) + (-0.629 * s + 0.0016 * l.T * s) * cos(4 * l.D - l.M) + -0.392 * s * cos(2 * (l.D - l.F)) + 0.297 * s * cos(10 * l.D) + 0.260 * s * cos(6 * l.D - l.M) + 0.201 * s * cos(3 * l.D) + -0.161 * s * cos(2 * l.D + l.M) + 0.157 * s * cos(l.D + l.M) + -0.138 * s * cos(12 * l.D) + -0.127 * s * cos(8 * l.D - l.M) + 0.104 * s * cos(2 * (l.D + l.F)) + 0.104 * s * cos(2 * (l.D - l.M)) + -0.079 * s * cos(5 * l.D) + 0.068 * s * cos(14 * l.D) + 0.067 * s * cos(10 * l.D - l.M) + 0.054 * s * cos(4 * l.D + l.M) + -0.038 * s * cos(12 * l.D - l.M) + -0.038 * s * cos(4 * l.D - 2 * l.M) + 0.037 * s * cos(7 * l.D) + -0.037 * s * cos(4 * l.D + 2 * l.F) + -0.035 * s * cos(16 * l.D) + -0.030 * s * cos(3 * l.D + l.M) + 0.029 * s * cos(l.D - l.M) + -0.025 * s * cos(6 * l.D + l.M) + 0.023 * s * cos(2 * l.M) + 0.023 * s * cos(14 * l.D - l.M) + -0.023 * s * cos(2 * (l.D + l.M)) + 0.022 * s * cos(6 * l.D - 2 * l.M) + -0.021 * s * cos(2 * l.D - 2 * l.F - l.M) + -0.020 * s * cos(9 * l.D) + 0.019 * s * cos(18 * l.D) + 0.017 * s * cos(6 * l.D + 2 * l.F) + 0.014 * s * cos(2 * l.F - l.M) + -0.014 * s * cos(16 * l.D - l.M) + 0.013 * s * cos(4 * l.D - 2 * l.F) + 0.012 * s * cos(8 * l.D + l.M) + 0.011 * s * cos(11 * l.D) + 0.010 * s * cos(5 * l.D + l.M) + -0.010 * s * cos(20 * l.D);
170 };
171
172 return La;
173}();
174
175export default {
176 EARTH_RADIUS: EARTH_RADIUS,
177 MOON_RADIUS: MOON_RADIUS,
178 meanPerigee: meanPerigee,
179 perigee: perigee,
180 meanApogee: meanApogee,
181 apogee: apogee,
182 apogeeParallax: apogeeParallax,
183 perigeeParallax: perigeeParallax,
184 distance: distance
185};
\No newline at end of file