1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | import base from './base';
|
12 | import interp from './interpolation';
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | export function time(r1, d1, r2, d2, r3, d3, t1, t5) {
|
36 |
|
37 | if (r3.length !== 5 || d3.length !== 5) {
|
38 | throw new Error('r3, d3 must be length 5');
|
39 | }
|
40 | var gc = new Array(5);
|
41 | r3.forEach(function (r3i, i) {
|
42 |
|
43 | gc[i] = Math.tan(d1) * Math.sin(r2 - r3i) + Math.tan(d2) * Math.sin(r3i - r1) + Math.tan(d3[i]) * Math.sin(r1 - r2);
|
44 | });
|
45 | var l5 = new interp.Len5(t1, t5, gc);
|
46 | return l5.zero(false);
|
47 | }
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | export function angle(r1, d1, r2, d2, r3, d3) {
|
59 |
|
60 | var _base$sincos = base.sincos(d2),
|
61 | sd2 = _base$sincos[0],
|
62 | cd2 = _base$sincos[1];
|
63 |
|
64 | var _base$sincos2 = base.sincos(r2 - r1),
|
65 | sr21 = _base$sincos2[0],
|
66 | cr21 = _base$sincos2[1];
|
67 |
|
68 | var _base$sincos3 = base.sincos(r3 - r2),
|
69 | sr32 = _base$sincos3[0],
|
70 | cr32 = _base$sincos3[1];
|
71 |
|
72 | var C1 = Math.atan2(sr21, cd2 * Math.tan(d1) - sd2 * cr21);
|
73 | var C2 = Math.atan2(sr32, cd2 * Math.tan(d3) - sd2 * cr32);
|
74 | return C1 + C2;
|
75 | }
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | export function error(r1, d1, r2, d2, r0, d0) {
|
86 |
|
87 | var _base$sincos4 = base.sincos(r1),
|
88 | sr1 = _base$sincos4[0],
|
89 | cr1 = _base$sincos4[1];
|
90 |
|
91 | var _base$sincos5 = base.sincos(d1),
|
92 | sd1 = _base$sincos5[0],
|
93 | cd1 = _base$sincos5[1];
|
94 |
|
95 | var _base$sincos6 = base.sincos(r2),
|
96 | sr2 = _base$sincos6[0],
|
97 | cr2 = _base$sincos6[1];
|
98 |
|
99 | var _base$sincos7 = base.sincos(d2),
|
100 | sd2 = _base$sincos7[0],
|
101 | cd2 = _base$sincos7[1];
|
102 |
|
103 | var X1 = cd1 * cr1;
|
104 | var X2 = cd2 * cr2;
|
105 | var Y1 = cd1 * sr1;
|
106 | var Y2 = cd2 * sr2;
|
107 | var Z1 = sd1;
|
108 | var Z2 = sd2;
|
109 | var A = Y1 * Z2 - Z1 * Y2;
|
110 | var B = Z1 * X2 - X1 * Z2;
|
111 | var C = X1 * Y2 - Y1 * X2;
|
112 | var m = Math.tan(r0);
|
113 | var n = Math.tan(d0) / Math.cos(r0);
|
114 | return Math.asin((A + B * m + C * n) / (Math.sqrt(A * A + B * B + C * C) * Math.sqrt(1 + m * m + n * n)));
|
115 | }
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 | export function angleError(r1, d1, r2, d2, r3, d3) {
|
128 | var _base$sincos8 = base.sincos(r1),
|
129 | sr1 = _base$sincos8[0],
|
130 | cr1 = _base$sincos8[1];
|
131 |
|
132 | var _base$sincos9 = base.sincos(d1),
|
133 | c1 = _base$sincos9[0],
|
134 | cd1 = _base$sincos9[1];
|
135 |
|
136 | var _base$sincos10 = base.sincos(r2),
|
137 | sr2 = _base$sincos10[0],
|
138 | cr2 = _base$sincos10[1];
|
139 |
|
140 | var _base$sincos11 = base.sincos(d2),
|
141 | c2 = _base$sincos11[0],
|
142 | cd2 = _base$sincos11[1];
|
143 |
|
144 | var _base$sincos12 = base.sincos(r3),
|
145 | sr3 = _base$sincos12[0],
|
146 | cr3 = _base$sincos12[1];
|
147 |
|
148 | var _base$sincos13 = base.sincos(d3),
|
149 | c3 = _base$sincos13[0],
|
150 | cd3 = _base$sincos13[1];
|
151 |
|
152 | var a1 = cd1 * cr1;
|
153 | var a2 = cd2 * cr2;
|
154 | var a3 = cd3 * cr3;
|
155 | var b1 = cd1 * sr1;
|
156 | var b2 = cd2 * sr2;
|
157 | var b3 = cd3 * sr3;
|
158 | var l1 = b1 * c2 - b2 * c1;
|
159 | var l2 = b2 * c3 - b3 * c2;
|
160 | var l3 = b1 * c3 - b3 * c1;
|
161 | var m1 = c1 * a2 - c2 * a1;
|
162 | var m2 = c2 * a3 - c3 * a2;
|
163 | var m3 = c1 * a3 - c3 * a1;
|
164 | var n1 = a1 * b2 - a2 * b1;
|
165 | var n2 = a2 * b3 - a3 * b2;
|
166 | var n3 = a1 * b3 - a3 * b1;
|
167 | var ψ = Math.acos((l1 * l2 + m1 * m2 + n1 * n2) / (Math.sqrt(l1 * l1 + m1 * m1 + n1 * n1) * Math.sqrt(l2 * l2 + m2 * m2 + n2 * n2)));
|
168 | var ω = Math.asin((a2 * l3 + b2 * m3 + c2 * n3) / (Math.sqrt(a2 * a2 + b2 * b2 + c2 * c2) * Math.sqrt(l3 * l3 + m3 * m3 + n3 * n3)));
|
169 | return [ψ, ω];
|
170 | }
|
171 |
|
172 | export default {
|
173 | time: time,
|
174 | angle: angle,
|
175 | error: error,
|
176 | angleError: angleError
|
177 | }; |
\ | No newline at end of file |