UNPKG

2.98 kBJavaScriptView Raw
1/**
2 * @copyright 2013 Sonia Keys
3 * @copyright 2016 commenthol
4 * @license MIT
5 * @module node
6 */
7/**
8 * Node: Chapter 39, Passages through the Nodes.
9 */
10
11import base from './base';
12
13/**
14 * EllipticAscending computes time and distance of passage through the ascending node of a body in an elliptical orbit.
15 *
16 * Argument axis is semimajor axis in AU, ecc is eccentricity, argP is argument
17 * of perihelion in radians, timeP is time of perihelion as a jd.
18 *
19 * Result is jde of the event and distance from the sun in AU.
20 */
21export function ellipticAscending(axis, ecc, argP, timeP) {
22 // (axis, ecc, argP, timeP float64) (jde, r float64)
23 return el(-argP, axis, ecc, timeP);
24}
25
26/**
27 * EllipticAscending computes time and distance of passage through the descending node of a body in an elliptical orbit.
28 *
29 * Argument axis is semimajor axis in AU, ecc is eccentricity, argP is argument
30 * of perihelion in radians, timeP is time of perihelion as a jd.
31 *
32 * Result is jde of the event and distance from the sun in AU.
33 */
34export function ellipticDescending(axis, ecc, argP, timeP) {
35 // (axis, ecc, argP, timeP float64) (jde, r float64)
36 return el(Math.PI - argP, axis, ecc, timeP);
37}
38
39export function el(ν, axis, ecc, timeP) {
40 // (ν, axis, ecc, timeP float64) (jde, r float64)
41 var E = 2 * Math.atan(Math.sqrt((1 - ecc) / (1 + ecc)) * Math.tan(ν * 0.5));
42
43 var _base$sincos = base.sincos(E),
44 sE = _base$sincos[0],
45 cE = _base$sincos[1];
46
47 var M = E - ecc * sE;
48 var n = base.K / axis / Math.sqrt(axis);
49 var jde = timeP + M / n;
50 var r = axis * (1 - ecc * cE);
51 return [jde, r];
52}
53
54/**
55 * ParabolicAscending computes time and distance of passage through the ascending node of a body in a parabolic orbit.
56 *
57 * Argument q is perihelion distance in AU, argP is argument of perihelion
58 * in radians, timeP is time of perihelion as a jd.
59 *
60 * Result is jde of the event and distance from the sun in AU.
61 */
62export function parabolicAscending(q, argP, timeP) {
63 // (q, argP, timeP float64) (jde, r float64)
64 return pa(-argP, q, timeP);
65}
66
67/**
68 * ParabolicDescending computes time and distance of passage through the descending node of a body in a parabolic orbit.
69 *
70 * Argument q is perihelion distance in AU, argP is argument of perihelion
71 * in radians, timeP is time of perihelion as a jd.
72 *
73 * Result is jde of the event and distance from the sun in AU.
74 */
75export function parabolicDescending(q, argP, timeP) {
76 // (q, argP, timeP float64) (jde, r float64)
77 return pa(Math.PI - argP, q, timeP);
78}
79
80export function pa(ν, q, timeP) {
81 // (ν, q, timeP float64) (jde, r float64)
82 var s = Math.tan(ν * 0.5);
83 var jde = timeP + 27.403895 * s * (s * s + 3) * q * Math.sqrt(q);
84 var r = q * (1 + s * s);
85 return [jde, r];
86}
87
88export default {
89 ellipticAscending: ellipticAscending,
90 ellipticDescending: ellipticDescending,
91 el: el,
92 parabolicAscending: parabolicAscending,
93 parabolicDescending: parabolicDescending,
94 pa: pa
95};
\No newline at end of file