UNPKG

3.48 kBJavaScriptView Raw
1/**
2 * @copyright 2013 Sonia Keys
3 * @copyright 2016 commenthol
4 * @license MIT
5 * @module parallactic
6 */
7/**
8 * Parallactic: Chapter 14, The Parallactic Angle, and three other Topics.
9 */
10
11import base from './base';
12
13/**
14 * ParallacticAngle returns parallactic angle of a celestial object.
15 *
16 * φ is geographic latitude of observer.
17 * δ is declination of observed object.
18 * H is hour angle of observed object.
19 *
20 * All angles including result are in radians.
21 */
22export function parallacticAngle(φ, δ, H) {
23 // (φ, δ, H float64) float64
24 var _base$sincos = base.sincos(δ),
25 sδ = _base$sincos[0],
26 cδ = _base$sincos[1];
27
28 var _base$sincos2 = base.sincos(H),
29 sH = _base$sincos2[0],
30 cH = _base$sincos2[1];
31
32 return Math.atan2(sH, Math.tan(φ) * cδ - sδ * cH); // (14.1) p. 98
33}
34
35/**
36 * ParallacticAngleOnHorizon is a special case of ParallacticAngle.
37 *
38 * The hour angle is not needed as an input and the math inside simplifies.
39 */
40export function parallacticAngleOnHorizon(φ, δ) {
41 // (φ, δ float64) float64
42 return Math.acos(Math.sin(φ) / Math.cos(δ));
43}
44
45/**
46 * EclipticAtHorizon computes how the plane of the ecliptic intersects
47 * the horizon at a given local sidereal time as observed from a given
48 * geographic latitude.
49 *
50 * ε is obliquity of the ecliptic.
51 * φ is geographic latitude of observer.
52 * θ is local sidereal time expressed as an hour angle.
53 *
54 * λ1 and λ2 are ecliptic longitudes where the ecliptic intersects the horizon.
55 * I is the angle at which the ecliptic intersects the horizon.
56 *
57 * All angles, arguments and results, are in radians.
58 */
59export function eclipticAtHorizon(ε, φ, θ) {
60 // (ε, φ, θ float64) (λ1, λ2, I float64)
61 var _base$sincos3 = base.sincos(ε),
62 sε = _base$sincos3[0],
63 cε = _base$sincos3[1];
64
65 var _base$sincos4 = base.sincos(φ),
66 sφ = _base$sincos4[0],
67 cφ = _base$sincos4[1];
68
69 var _base$sincos5 = base.sincos(θ),
70 sθ = _base$sincos5[0],
71 cθ = _base$sincos5[1];
72
73 var λ = Math.atan2(-cθ, sε * (sφ / cφ) + cε * sθ); // (14.2) p. 99
74 if (λ < 0) {
75 λ += Math.PI;
76 }
77 return [λ, λ + Math.PI, Math.acos(cε * sφ - sε * cφ * sθ)]; // (14.3) p. 99
78}
79
80/**
81 * EclipticAtEquator computes the angle between the ecliptic and the parallels
82 * of ecliptic latitude at a given ecliptic longitude.
83 *
84 * (The function name EclipticAtEquator is for consistency with the Meeus text,
85 * and works if you consider the equator a nominal parallel of latitude.)
86 *
87 * λ is ecliptic longitude.
88 * ε is obliquity of the ecliptic.
89 *
90 * All angles in radians.
91 */
92export function eclipticAtEquator(λ, ε) {
93 // (λ, ε float64) float64
94 return Math.atan(-Math.cos(λ) * Math.tan(ε));
95}
96
97/**
98 * DiurnalPathAtHorizon computes the angle of the path a celestial object
99 * relative to the horizon at the time of its rising or setting.
100 *
101 * δ is declination of the object.
102 * φ is geographic latitude of observer.
103 *
104 * All angles in radians.
105 */
106export function diurnalPathAtHorizon(δ, φ) {
107 // (δ, φ float64) (J float64)
108 var tφ = Math.tan(φ);
109 var b = Math.tan(δ) * tφ;
110 var c = Math.sqrt(1 - b * b);
111 return Math.atan(c * Math.cos(δ) / tφ);
112}
113
114export default {
115 parallacticAngle: parallacticAngle,
116 parallacticAngleOnHorizon: parallacticAngleOnHorizon,
117 eclipticAtHorizon: eclipticAtHorizon,
118 eclipticAtEquator: eclipticAtEquator,
119 diurnalPathAtHorizon: diurnalPathAtHorizon
120};
\No newline at end of file