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