1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.planetary = planetary;
|
7 | exports.stellar = stellar;
|
8 |
|
9 | var _interpolation = require('./interpolation');
|
10 |
|
11 | var _interpolation2 = _interopRequireDefault(_interpolation);
|
12 |
|
13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14 |
|
15 | /**
|
16 | * Planetary computes a conjunction between two moving objects, such as planets.
|
17 | *
|
18 | * Conjunction is found with interpolation against length 5 ephemerides.
|
19 | *
|
20 | * t1, t5 are times of first and last rows of ephemerides. The scale is
|
21 | * arbitrary.
|
22 | *
|
23 | * cs1 is the ephemeris of the first object. The columns may be celestial
|
24 | * coordinates in right ascension and declination or ecliptic coordinates in
|
25 | * longitude and latitude.
|
26 | *
|
27 | * cs2 is the ephemeris of the second object, in the same frame as the first.
|
28 | *
|
29 | * Return value t is time of conjunction in the scale of t1, t5.
|
30 | *
|
31 | * @param {Number} t1 - julian ephemeris day of first row
|
32 | * @param {Number} t5 - julian ephemeris day of fifth row
|
33 | * @param {base.Coord[]} cs1 - ephemeris of first moving object
|
34 | * @param {base.Coord[]} cs2 - ephemeris of decond moving object
|
35 | * @return {Array}
|
36 | * {Number} t - time of conjunction in JDE
|
37 | * {Number} Δd - is the amount that object 2 was "above" object 1 at the time of conjunction.
|
38 | */
|
39 | function planetary(t1, t5, cs1, cs2) {
|
40 | if (cs1.length !== 5 || cs2.length !== 5) {
|
41 | throw new Error('Five rows required in ephemerides');
|
42 | }
|
43 | var dr = new Array(5);
|
44 | var dd = new Array(5);
|
45 | cs1.forEach(function (r, i) {
|
46 | dr[i] = cs2[i].ra - cs1[i].ra;
|
47 | dd[i] = cs2[i].dec - cs1[i].dec;
|
48 | });
|
49 | return conj(t1, t5, dr, dd);
|
50 | }
|
51 |
|
52 | /**
|
53 | * Stellar computes a conjunction between a moving and non-moving object.
|
54 | *
|
55 | * Arguments and return values same as with Planetary, except the non-moving
|
56 | * object is c1. The ephemeris of the moving object is cs2.
|
57 | *
|
58 | * @param {Number} t1 - julian ephemeris day of first row
|
59 | * @param {Number} t5 - julian ephemeris day of fifth row
|
60 | * @param {base.Coord} c1 - ephemeris of non-moving object
|
61 | * @param {base.Coord[]} cs2 - ephemeris of moving object
|
62 | * @return {Array}
|
63 | * {Number} t - time of conjunction in JDE
|
64 | * {Number} Δd - is the amount that object 2 was "above" object 1 at the time of conjunction.
|
65 | */
|
66 | /**
|
67 | * @copyright 2013 Sonia Keys
|
68 | * @copyright 2016 commenthol
|
69 | * @license MIT
|
70 | * @module conjunction
|
71 | */
|
72 | /**
|
73 | * Conjunction: Chapter 18: Planetary Conjunctions.
|
74 | */
|
75 |
|
76 | function stellar(t1, t5, c1, cs2) {
|
77 | if (cs2.length !== 5) {
|
78 | throw new Error('Five rows required in ephemerides');
|
79 | }
|
80 | var dr = new Array(5);
|
81 | var dd = new Array(5);
|
82 | cs2.forEach(function (r, i) {
|
83 | dr[i] = cs2[i].ra - c1.ra;
|
84 | dd[i] = cs2[i].dec - c1.dec;
|
85 | });
|
86 | return conj(t1, t5, dr, dd);
|
87 | }
|
88 |
|
89 | var conj = function conj(t1, t5, dr, dd) {
|
90 | // (t1, t5 float64, dr, dd []float64) (t, Δd float64, err error)
|
91 | var l5 = new _interpolation2.default.Len5(t1, t5, dr);
|
92 | var t = l5.zero(true);
|
93 | l5 = new _interpolation2.default.Len5(t1, t5, dd);
|
94 | var Δd = l5.interpolateXStrict(t);
|
95 | return [t, Δd];
|
96 | };
|
97 |
|
98 | exports.default = {
|
99 | planetary: planetary,
|
100 | stellar: stellar
|
101 | }; |
\ | No newline at end of file |