1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | export function sum(m1, m2) {
|
15 |
|
16 | var x = 0.4 * (m2 - m1);
|
17 | return m2 - 2.5 * Math.log10(Math.pow(10, x) + 1);
|
18 | }
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export function sumN(m) {
|
24 |
|
25 | var s = 0;
|
26 | for (var _iterator = m, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
27 | var _ref;
|
28 |
|
29 | if (_isArray) {
|
30 | if (_i >= _iterator.length) break;
|
31 | _ref = _iterator[_i++];
|
32 | } else {
|
33 | _i = _iterator.next();
|
34 | if (_i.done) break;
|
35 | _ref = _i.value;
|
36 | }
|
37 |
|
38 | var mi = _ref;
|
39 |
|
40 | s += Math.pow(10, -0.4 * mi);
|
41 | }
|
42 | return -2.5 * Math.log10(s);
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | export function ratio(m1, m2) {
|
51 |
|
52 | var x = 0.4 * (m2 - m1);
|
53 | return Math.pow(10, x);
|
54 | }
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | export function difference(ratio) {
|
61 |
|
62 | return 2.5 * Math.log10(ratio);
|
63 | }
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 | export function absoluteByParallax(m, π) {
|
71 |
|
72 | return m + 5 + 5 * Math.log10(π);
|
73 | }
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | export function absoluteByDistance(m, d) {
|
81 |
|
82 | return m + 5 - 5 * Math.log10(d);
|
83 | }
|
84 |
|
85 | export default {
|
86 | sum: sum,
|
87 | sumN: sumN,
|
88 | ratio: ratio,
|
89 | difference: difference,
|
90 | absoluteByParallax: absoluteByParallax,
|
91 | absoluteByDistance: absoluteByDistance
|
92 | }; |
\ | No newline at end of file |