1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); /**
|
8 | * @copyright 2013 Sonia Keys
|
9 | * @copyright 2016 commenthol
|
10 | * @license MIT
|
11 | * @module moonillum
|
12 | */
|
13 | /**
|
14 | * Moonillum: Chapter 48, Illuminated Fraction of the Moon's Disk
|
15 | *
|
16 | * Also see functions `illuminated` and `limb` in package base. The function
|
17 | * for computing illuminated fraction given a phase angle (48.1) is
|
18 | * base.illuminated. Formula (48.3) is implemented as base.limb.
|
19 | */
|
20 |
|
21 | exports.phaseAngleEquatorial = phaseAngleEquatorial;
|
22 | exports.phaseAngleEquatorial2 = phaseAngleEquatorial2;
|
23 | exports.phaseAngleEcliptic = phaseAngleEcliptic;
|
24 | exports.phaseAngleEcliptic2 = phaseAngleEcliptic2;
|
25 | exports.phaseAngle3 = phaseAngle3;
|
26 |
|
27 | var _base = require('./base');
|
28 |
|
29 | var _base2 = _interopRequireDefault(_base);
|
30 |
|
31 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
32 |
|
33 | var p = Math.PI / 180;
|
34 |
|
35 | /**
|
36 | * phaseAngleEquatorial computes the phase angle of the Moon given equatorial coordinates.
|
37 | *
|
38 | * @param {base.Coord} cMoon - geocentric right ascension, declination and distance to the Moon
|
39 | * @param {base.Coord} cSun - coordinates and distance of the Sun
|
40 | * @returns {number} phase angle of the Moon in radians
|
41 | */
|
42 | function phaseAngleEquatorial(cMoon, cSun) {
|
43 | return pa(cMoon.range, cSun.range, cosEq(cMoon.ra, cMoon.dec, cSun.ra, cSun.dec));
|
44 | }
|
45 |
|
46 | /**
|
47 | * cos elongation from equatorial coordinates
|
48 | * @private
|
49 | */
|
50 | function cosEq(α, δ, α0, δ0) {
|
51 | var _base$sincos = _base2.default.sincos(δ),
|
52 | _base$sincos2 = _slicedToArray(_base$sincos, 2),
|
53 | sδ = _base$sincos2[0],
|
54 | cδ = _base$sincos2[1];
|
55 |
|
56 | var _base$sincos3 = _base2.default.sincos(δ0),
|
57 | _base$sincos4 = _slicedToArray(_base$sincos3, 2),
|
58 | sδ0 = _base$sincos4[0],
|
59 | cδ0 = _base$sincos4[1];
|
60 |
|
61 | return sδ0 * sδ + cδ0 * cδ * Math.cos(α0 - α);
|
62 | }
|
63 |
|
64 | /**
|
65 | * phase angle from cos elongation and distances
|
66 | * @private
|
67 | * @param {number} Δ
|
68 | * @param {number} R
|
69 | * @param {number} cψ
|
70 | * @returns {number}
|
71 | */
|
72 | function pa(Δ, R, cψ) {
|
73 | var sψ = Math.sin(Math.acos(cψ));
|
74 | var i = Math.atan(R * sψ / (Δ - R * cψ));
|
75 | if (i < 0) {
|
76 | i += Math.PI;
|
77 | }
|
78 | return i;
|
79 | }
|
80 |
|
81 | /**
|
82 | * phaseAngleEquatorial2 computes the phase angle of the Moon given equatorial coordinates.
|
83 | *
|
84 | * Less accurate than phaseAngleEquatorial.
|
85 | *
|
86 | * Arguments α, δ are geocentric right ascension and declination of the Moon;
|
87 | * α0, δ0 are coordinates of the Sun. Angles must be in radians.
|
88 | *
|
89 | * @param {base.Coord} cMoon - eocentric right ascension and declination of the Moon
|
90 | * @param {base.Coord} cSun - coordinates of the Sun
|
91 | * @returns {number} phase angle of the Moon in radians
|
92 | */
|
93 | function phaseAngleEquatorial2(cMoon, cSun) {
|
94 | return Math.acos(-cosEq(cMoon.ra, cMoon.dec, cSun.ra, cSun.dec));
|
95 | }
|
96 |
|
97 | /**
|
98 | * phaseAngleEcliptic computes the phase angle of the Moon given ecliptic coordinates.
|
99 | *
|
100 | * Distances must be in the same units as each other.
|
101 | *
|
102 | * @param {base.Coord} cMoon - geocentric longitude, latitude and distance to the Moon
|
103 | * @param {base.Coord} cSun - longitude and distance to the Sun
|
104 | * @returns {number} phase angle of the Moon in radians
|
105 | */
|
106 | function phaseAngleEcliptic(cMoon, cSun) {
|
107 | return pa(cMoon.range, cSun.range, cosEcl(cMoon.lon, cMoon.lat, cSun.lon));
|
108 | }
|
109 |
|
110 | /**
|
111 | * cos elongation from ecliptic coordinates
|
112 | * @private
|
113 | */
|
114 | function cosEcl(λ, β, λ0) {
|
115 | // (λ, β, λ0 float64) float64
|
116 | return Math.cos(β) * Math.cos(λ - λ0);
|
117 | }
|
118 |
|
119 | /**
|
120 | * phaseAngleEcliptic2 computes the phase angle of the Moon given ecliptic coordinates.
|
121 | *
|
122 | * Less accurate than phaseAngleEcliptic.
|
123 | *
|
124 | * Angles must be in radians.
|
125 | *
|
126 | * @param {base.Coord} cMoon - geocentric longitude, latitude of the Moon
|
127 | * @param {base.Coord} cSun - longitude of the Sun
|
128 | * @returns {number} phase angle of the Moon in radians
|
129 | */
|
130 | function phaseAngleEcliptic2(cMoon, cSun) {
|
131 | return Math.acos(-cosEcl(cMoon.lon, cMoon.lat, cSun.lon));
|
132 | }
|
133 |
|
134 | /**
|
135 | * phaseAngle3 computes the phase angle of the Moon given a julian day.
|
136 | *
|
137 | * Less accurate than phaseAngle functions taking coordinates.
|
138 | *
|
139 | * Result in radians.
|
140 | */
|
141 | function phaseAngle3(jde) {
|
142 | // (jde float64) float64
|
143 | var T = _base2.default.J2000Century(jde);
|
144 | var D = _base2.default.horner(T, 297.8501921 * p, 445267.1114034 * p, -0.0018819 * p, p / 545868, -p / 113065000);
|
145 | var m = _base2.default.horner(T, 357.5291092 * p, 35999.0502909 * p, -0.0001535 * p, p / 24490000);
|
146 | var m_ = _base2.default.horner(T, 134.9633964 * p, 477198.8675055 * p, 0.0087414 * p, p / 69699, -p / 14712000);
|
147 | return Math.PI - _base2.default.pmod(D, 2 * Math.PI) + -6.289 * p * Math.sin(m_) + 2.1 * p * Math.sin(m) + -1.274 * p * Math.sin(2 * D - m_) + -0.658 * p * Math.sin(2 * D) + -0.214 * p * Math.sin(2 * m_) + -0.11 * p * Math.sin(D);
|
148 | }
|
149 |
|
150 | exports.default = {
|
151 | phaseAngleEquatorial: phaseAngleEquatorial,
|
152 | phaseAngleEquatorial2: phaseAngleEquatorial2,
|
153 | phaseAngleEcliptic: phaseAngleEcliptic,
|
154 | phaseAngleEcliptic2: phaseAngleEcliptic2,
|
155 | phaseAngle3: phaseAngle3
|
156 | }; |
\ | No newline at end of file |