1 | /**
|
2 | * @copyright 2013 Sonia Keys
|
3 | * @copyright 2016 commenthol
|
4 | * @license MIT
|
5 | * @module illum
|
6 | */
|
7 | /**
|
8 | * Illum: Chapter 41, Illuminated Fraction of the Disk and Magnitude of a Planet.
|
9 | *
|
10 | * Also see functions `illuminated` and `limb` in package base. While this
|
11 | * chapter title includes "illumnated fraction," the function for computing
|
12 | * illuminated fraction given a phase angle is `base.illuminated`.
|
13 | * `base.limb` is the function mentioned at the bottom of p. 283.0
|
14 | */
|
15 |
|
16 | import base from './base';
|
17 |
|
18 | /**
|
19 | * PhaseAngle computes the phase angle of a planet.
|
20 | *
|
21 | * Argument r is planet's distance to Sun, Δ its distance to Earth, and R
|
22 | * the distance from Sun to Earth. All distances in AU.
|
23 | *
|
24 | * Result in radians.
|
25 | */
|
26 | export function phaseAngle(r, Δ, R) {
|
27 | // (r, Δ, R float64) float64
|
28 | return Math.acos((r * r + Δ * Δ - R * R) / (2 * r * Δ));
|
29 | }
|
30 |
|
31 | /**
|
32 | * Fraction computes the illuminated fraction of the disk of a planet.
|
33 | *
|
34 | * Argument r is planet's distance to Sun, Δ its distance to Earth, and R
|
35 | * the distance from Sun to Earth. All distances in AU.
|
36 | */
|
37 | export function fraction(r, Δ, R) {
|
38 | // (r, Δ, R float64) float64
|
39 | // (41.2) p. 283
|
40 | var s = r + Δ;
|
41 | return (s * s - R * R) / (4 * r * Δ);
|
42 | }
|
43 |
|
44 | /**
|
45 | * PhaseAngle2 computes the phase angle of a planet.
|
46 | *
|
47 | * Arguments L, B, R are heliocentric ecliptical coordinates of the planet.
|
48 | * L0, R0 are longitude and radius for Earth, Δ is distance from Earth to
|
49 | * the planet. All distances in AU, angles in radians.
|
50 | *
|
51 | * The phase angle result is in radians.
|
52 | */
|
53 | export function phaseAngle2(L, B, R, L0, R0, Δ) {
|
54 | // (L, B, R, L0, R0, Δ float64) float64
|
55 | // (41.3) p. 283
|
56 | return Math.acos((R - R0 * Math.cos(B) * Math.cos(L - L0)) / Δ);
|
57 | }
|
58 |
|
59 | /**
|
60 | * PhaseAngle3 computes the phase angle of a planet.
|
61 | *
|
62 | * Arguments L, B are heliocentric ecliptical longitude and latitude of the
|
63 | * planet. x, y, z are cartesian coordinates of the planet, Δ is distance
|
64 | * from Earth to the planet. All distances in AU, angles in radians.
|
65 | *
|
66 | * The phase angle result is in radians.
|
67 | */
|
68 | export function phaseAngle3(L, B, x, y, z, Δ) {
|
69 | // (L, B, x, y, z, Δ float64) float64
|
70 | // (41.4) p. 283
|
71 | var _base$sincos = base.sincos(L),
|
72 | sL = _base$sincos[0],
|
73 | cL = _base$sincos[1];
|
74 |
|
75 | var _base$sincos2 = base.sincos(B),
|
76 | sB = _base$sincos2[0],
|
77 | cB = _base$sincos2[1];
|
78 |
|
79 | return Math.acos((x * cB * cL + y * cB * sL + z * sB) / Δ);
|
80 | }
|
81 |
|
82 | var p = Math.PI / 180;
|
83 |
|
84 | /**
|
85 | * FractionVenus computes an approximation of the illumanted fraction of Venus.
|
86 | */
|
87 | export function fractionVenus(jde) {
|
88 | // (jde float64) float64
|
89 | var T = base.J2000Century(jde);
|
90 | var V = 261.51 * p + 22518.443 * p * T;
|
91 | var M = 177.53 * p + 35999.05 * p * T;
|
92 | var N = 50.42 * p + 58517.811 * p * T;
|
93 | var W = V + 1.91 * p * Math.sin(M) + 0.78 * p * Math.sin(N);
|
94 | var Δ = Math.sqrt(1.52321 + 1.44666 * Math.cos(W));
|
95 | var s = 0.72333 + Δ;
|
96 | return (s * s - 1) / 2.89332 / Δ;
|
97 | }
|
98 |
|
99 | /**
|
100 | * Mercury computes the visual magnitude of Mercury.
|
101 | *
|
102 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth,
|
103 | * and i the phase angle in radians.
|
104 | */
|
105 | export function mercury(r, Δ, i) {
|
106 | // (r, Δ, i float64) float64
|
107 | var s = i - 50 * p;
|
108 | return 1.16 + 5 * Math.log10(r * Δ) + 0.02838 / p * s + 0.0001023 / p / p * s * s;
|
109 | }
|
110 |
|
111 | /**
|
112 | * Venus computes the visual magnitude of Venus.
|
113 | *
|
114 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth,
|
115 | * and i the phase angle in radians.
|
116 | */
|
117 | export function venus(r, Δ, i) {
|
118 | // (r, Δ, i float64) float64
|
119 | return -4 + 5 * Math.log10(r * Δ) + (0.01322 / p + 0.0000004247 / p / p / p * i * i) * i;
|
120 | }
|
121 |
|
122 | /**
|
123 | * Mars computes the visual magnitude of Mars.
|
124 | *
|
125 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth,
|
126 | * and i the phase angle in radians.
|
127 | */
|
128 | export function mars(r, Δ, i) {
|
129 | // (r, Δ, i float64) float64
|
130 | return -1.3 + 5 * Math.log10(r * Δ) + 0.01486 / p * i;
|
131 | }
|
132 |
|
133 | /**
|
134 | * Jupiter computes the visual magnitude of Jupiter.
|
135 | *
|
136 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth.
|
137 | */
|
138 | export function jupiter(r, Δ) {
|
139 | // (r, Δ float64) float64
|
140 | return -8.93 + 5 * Math.log10(r * Δ);
|
141 | }
|
142 |
|
143 | /**
|
144 | * Saturn computes the visual magnitude of Saturn.
|
145 | *
|
146 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth.
|
147 | * B is the Saturnicentric latitude of the Earth referred to the plane of
|
148 | * Saturn's ring. ΔU is the difference between the Saturnicentric longitudes
|
149 | * of the Sun and the Earth, measured in the plane of the ring.
|
150 | * You can use saturndisk.Disk() to obtain B and ΔU.
|
151 | */
|
152 | export function saturn(r, Δ, B, ΔU) {
|
153 | // (r, Δ, B, ΔU float64) float64
|
154 | var s = Math.sin(Math.abs(B));
|
155 | return -8.68 + 5 * Math.log10(r * Δ) + 0.044 / p * Math.abs(ΔU) - 2.6 * s + 1.25 * s * s;
|
156 | }
|
157 |
|
158 | /**
|
159 | * Uranus computes the visual magnitude of Uranus.
|
160 | *
|
161 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth.
|
162 | */
|
163 | export function uranus(r, Δ) {
|
164 | // (r, Δ float64) float64
|
165 | return -6.85 + 5 * Math.log10(r * Δ);
|
166 | }
|
167 |
|
168 | /**
|
169 | * Neptune computes the visual magnitude of Neptune.
|
170 | *
|
171 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth.
|
172 | */
|
173 | export function neptune(r, Δ) {
|
174 | // (r, Δ float64) float64
|
175 | return -7.05 + 5 * Math.log10(r * Δ);
|
176 | }
|
177 |
|
178 | /**
|
179 | * Mercury84 computes the visual magnitude of Mercury.
|
180 | *
|
181 | * The formula is that adopted in "Astronomical Almanac" in 1984.0
|
182 | *
|
183 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth,
|
184 | * and i the phase angle in radians.
|
185 | */
|
186 | export function mercury84(r, Δ, i) {
|
187 | // (r, Δ, i float64) float64
|
188 | return base.horner(i, -0.42 + 5 * Math.log10(r * Δ), 0.038 / p, -0.000273 / p / p, 0.000002 / p / p / p);
|
189 | }
|
190 |
|
191 | /**
|
192 | * Venus84 computes the visual magnitude of Venus.
|
193 | *
|
194 | * The formula is that adopted in "Astronomical Almanac" in 1984.0
|
195 | *
|
196 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth,
|
197 | * and i the phase angle in radians.
|
198 | */
|
199 | export function venus84(r, Δ, i) {
|
200 | // (r, Δ, i float64) float64
|
201 | return base.horner(i, -4.4 + 5 * Math.log10(r * Δ), 0.0009 / p, -0.000239 / p / p, 0.00000065 / p / p / p);
|
202 | }
|
203 |
|
204 | /**
|
205 | * Mars84 computes the visual magnitude of Mars.
|
206 | *
|
207 | * The formula is that adopted in "Astronomical Almanac" in 1984.0
|
208 | *
|
209 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth,
|
210 | * and i the phase angle in radians.
|
211 | */
|
212 | export function mars84(r, Δ, i) {
|
213 | // (r, Δ, i float64) float64
|
214 | return -1.52 + 5 * Math.log10(r * Δ) + 0.016 / p * i;
|
215 | }
|
216 |
|
217 | /**
|
218 | * Jupiter84 computes the visual magnitude of Jupiter.
|
219 | *
|
220 | * The formula is that adopted in "Astronomical Almanac" in 1984.0
|
221 | *
|
222 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth,
|
223 | * and i the phase angle in radians.
|
224 | */
|
225 | export function jupiter84(r, Δ, i) {
|
226 | // (r, Δ, i float64) float64
|
227 | return -9.4 + 5 * Math.log10(r * Δ) + 0.005 / p * i;
|
228 | }
|
229 |
|
230 | /**
|
231 | * Saturn84 computes the visual magnitude of Saturn.
|
232 | *
|
233 | * The formula is that adopted in "Astronomical Almanac" in 1984.0
|
234 | *
|
235 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth.
|
236 | * B is the Saturnicentric latitude of the Earth referred to the plane of
|
237 | * Saturn's ring. ΔU is the difference between the Saturnicentric longitudes
|
238 | * of the Sun and the Earth, measured in the plane of the ring.
|
239 | */
|
240 | export function saturn84(r, Δ, B, ΔU) {
|
241 | // (r, Δ, B, ΔU float64) float64
|
242 | var s = Math.sin(Math.abs(B));
|
243 | return -8.88 + 5 * Math.log10(r * Δ) + 0.044 / p * Math.abs(ΔU) - 2.6 * s + 1.25 * s * s;
|
244 | }
|
245 |
|
246 | /**
|
247 | * Uranus84 computes the visual magnitude of Uranus.
|
248 | *
|
249 | * The formula is that adopted in "Astronomical Almanac" in 1984.0
|
250 | *
|
251 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth.
|
252 | */
|
253 | export function uranus84(r, Δ) {
|
254 | // (r, Δ float64) float64
|
255 | return -7.19 + 5 * Math.log10(r * Δ);
|
256 | }
|
257 |
|
258 | /**
|
259 | * Neptune84 computes the visual magnitude of Neptune.
|
260 | *
|
261 | * The formula is that adopted in "Astronomical Almanac" in 1984.0
|
262 | *
|
263 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth.
|
264 | */
|
265 | export function neptune84(r, Δ) {
|
266 | // (r, Δ float64) float64
|
267 | return -6.87 + 5 * Math.log10(r * Δ);
|
268 | }
|
269 |
|
270 | /**
|
271 | * Pluto84 computes the visual magnitude of Pluto.
|
272 | *
|
273 | * The formula is that adopted in "Astronomical Almanac" in 1984.0
|
274 | *
|
275 | * Argument r is the planet's distance from the Sun, Δ the distance from Earth.
|
276 | */
|
277 | export function pluto84(r, Δ) {
|
278 | // (r, Δ float64) float64
|
279 | return -1 + 5 * Math.log10(r * Δ);
|
280 | }
|
281 |
|
282 | export default {
|
283 | phaseAngle: phaseAngle,
|
284 | fraction: fraction,
|
285 | phaseAngle2: phaseAngle2,
|
286 | phaseAngle3: phaseAngle3,
|
287 | fractionVenus: fractionVenus,
|
288 | mercury: mercury,
|
289 | venus: venus,
|
290 | mars: mars,
|
291 | jupiter: jupiter,
|
292 | saturn: saturn,
|
293 | uranus: uranus,
|
294 | neptune: neptune,
|
295 | mercury84: mercury84,
|
296 | venus84: venus84,
|
297 | mars84: mars84,
|
298 | jupiter84: jupiter84,
|
299 | saturn84: saturn84,
|
300 | uranus84: uranus84,
|
301 | neptune84: neptune84,
|
302 | pluto84: pluto84
|
303 | }; |
\ | No newline at end of file |