@ac-kit/math-geodesy 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/LICENSE +57 -0
- package/README.md +89 -2
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_ecef-forward-bound.d.ts +7 -0
- package/dist/_ecef-forward-bound.d.ts.map +1 -0
- package/dist/_ecef-forward-bound.js +7 -0
- package/dist/_ecef-forward-bound.js.map +1 -0
- package/dist/_ecef-height.d.ts +31 -0
- package/dist/_ecef-height.d.ts.map +1 -0
- package/dist/_ecef-height.js +99 -0
- package/dist/_ecef-height.js.map +1 -0
- package/dist/ellipsoid.d.ts +52 -0
- package/dist/ellipsoid.d.ts.map +1 -0
- package/dist/ellipsoid.js +75 -0
- package/dist/ellipsoid.js.map +1 -0
- package/dist/geodesic/_angle.d.ts +51 -0
- package/dist/geodesic/_angle.d.ts.map +1 -0
- package/dist/geodesic/_angle.js +129 -0
- package/dist/geodesic/_angle.js.map +1 -0
- package/dist/geodesic/_constants.d.ts +38 -0
- package/dist/geodesic/_constants.d.ts.map +1 -0
- package/dist/geodesic/_constants.js +141 -0
- package/dist/geodesic/_constants.js.map +1 -0
- package/dist/geodesic/_inverse.d.ts +22 -0
- package/dist/geodesic/_inverse.d.ts.map +1 -0
- package/dist/geodesic/_inverse.js +714 -0
- package/dist/geodesic/_inverse.js.map +1 -0
- package/dist/geodesic/_line.d.ts +38 -0
- package/dist/geodesic/_line.d.ts.map +1 -0
- package/dist/geodesic/_line.js +214 -0
- package/dist/geodesic/_line.js.map +1 -0
- package/dist/geodesic/_series.d.ts +69 -0
- package/dist/geodesic/_series.d.ts.map +1 -0
- package/dist/geodesic/_series.js +203 -0
- package/dist/geodesic/_series.js.map +1 -0
- package/dist/geodesic.d.ts +84 -0
- package/dist/geodesic.d.ts.map +1 -0
- package/dist/geodesic.js +197 -0
- package/dist/geodesic.js.map +1 -0
- package/dist/geodetic.d.ts +194 -0
- package/dist/geodetic.d.ts.map +1 -0
- package/dist/geodetic.js +430 -0
- package/dist/geodetic.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/local-frame.d.ts +19 -0
- package/dist/local-frame.d.ts.map +1 -0
- package/dist/local-frame.js +35 -0
- package/dist/local-frame.js.map +1 -0
- package/package.json +72 -3
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*! Derived from GeographicLib Math.js (geographiclib-geodesic 2.2.0), Copyright (c) 2011-2022, Charles Karney, MIT License — see LICENSE. */
|
|
2
|
+
import { copySign, DEG_TO_RAD, twoSumError } from "@ac-kit/math-scalar";
|
|
3
|
+
export function scratchCreate_(length) {
|
|
4
|
+
return new Float64Array(length);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The smallest sine or cosine the port keeps away from zero, `sqrt(min normal
|
|
8
|
+
* double)`, so a pole never gives a division by exactly zero.
|
|
9
|
+
*/
|
|
10
|
+
export const TINY_ = Math.sqrt(Number.MIN_VALUE / Number.EPSILON);
|
|
11
|
+
/**
|
|
12
|
+
* {@link TINY_} in a buffer, read as `TINY_DOUBLE_[0]` where it is assigned to
|
|
13
|
+
* a variable that otherwise holds computed doubles: the module binding is a
|
|
14
|
+
* tagged value, and V8 then boxes that variable on every path.
|
|
15
|
+
*/
|
|
16
|
+
export const TINY_DOUBLE_ = Float64Array.of(TINY_);
|
|
17
|
+
/** `x` modulo `period` in `[−period/2, period/2]`, exactly (period positive). */
|
|
18
|
+
function remainder_(x, period) {
|
|
19
|
+
const reduced = x % period;
|
|
20
|
+
if (reduced < -period / 2) {
|
|
21
|
+
return reduced + period;
|
|
22
|
+
}
|
|
23
|
+
return reduced < period / 2 ? reduced : reduced - period;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Snaps an angle within 1/16° of zero onto a grid of 2⁻⁵⁷°, so a latitude that
|
|
27
|
+
* is zero up to rounding is treated as the equator. Tiny negatives become `−0`,
|
|
28
|
+
* and `−0` becomes `+0`.
|
|
29
|
+
*/
|
|
30
|
+
export function angleRound_(x) {
|
|
31
|
+
const grid = 1 / 16;
|
|
32
|
+
const magnitude = Math.abs(x);
|
|
33
|
+
// `grid - (grid - magnitude)` is not `magnitude`: the rounding is the point.
|
|
34
|
+
const rounded = magnitude < grid ? grid - (grid - magnitude) : magnitude;
|
|
35
|
+
return copySign(rounded, x);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `x` reduced to `[−180, 180]`; a result of ±180 or ±0 takes the sign of `x`.
|
|
39
|
+
*
|
|
40
|
+
* The rare result `copySign(180, x)` is computed on every path, here and in the
|
|
41
|
+
* functions below: a call that has never run has no type feedback, V8 cannot
|
|
42
|
+
* inline it, and merging its boxed result with a computed double makes V8 box
|
|
43
|
+
* that double on the common path too.
|
|
44
|
+
*/
|
|
45
|
+
export function angleNormalize_(x) {
|
|
46
|
+
const reduced = remainder_(x, 360);
|
|
47
|
+
const halfTurn = copySign(180, x);
|
|
48
|
+
return Math.abs(reduced) === 180 ? halfTurn : reduced;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `io[1] − io[0]` reduced to `[−180, 180]`, written back as `io[0] + io[1]`:
|
|
52
|
+
* `io[0]` is the nearest double and `io[1]` the rounding error, below 2⁻²⁶. A
|
|
53
|
+
* result of ±0 or ±180 takes the sign of the difference (of `−error` when the
|
|
54
|
+
* error is not zero). (Doubles travel in the buffer: a call passing them as
|
|
55
|
+
* arguments could box them.)
|
|
56
|
+
*/
|
|
57
|
+
export function angleDifference_(io) {
|
|
58
|
+
const x = io[0];
|
|
59
|
+
const y = io[1];
|
|
60
|
+
const first = remainder_(-x, 360);
|
|
61
|
+
const second = remainder_(y, 360);
|
|
62
|
+
let sum = first + second;
|
|
63
|
+
let error = sum === 0 ? sum : twoSumError(first, second, sum);
|
|
64
|
+
const reducedSum = remainder_(sum, 360);
|
|
65
|
+
sum = reducedSum + error;
|
|
66
|
+
error = sum === 0 ? sum : twoSumError(reducedSum, error, sum);
|
|
67
|
+
const signedSum = copySign(sum, error === 0 ? y - x : -error);
|
|
68
|
+
if (sum === 0 || Math.abs(sum) === 180) {
|
|
69
|
+
sum = signedSum;
|
|
70
|
+
}
|
|
71
|
+
io[0] = sum;
|
|
72
|
+
io[1] = error;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Sine and cosine, written to `io[0]` and `io[1]`, of `io[0] + io[1]` degrees,
|
|
76
|
+
* where `io[1]` is the small error term of {@link angleDifference_}. The
|
|
77
|
+
* argument is reduced to `[−45, 45]` before the conversion to radians and the
|
|
78
|
+
* reduced sum snapped by {@link angleRound_} (upstream's `sincosde`, whose
|
|
79
|
+
* contract no `math-scalar` function has); 30° and 45° give their exact
|
|
80
|
+
* algebraic values.
|
|
81
|
+
*/
|
|
82
|
+
export function sineCosineCorrected_(io) {
|
|
83
|
+
const x = io[0];
|
|
84
|
+
const correction = io[1];
|
|
85
|
+
const reduced = x % 360;
|
|
86
|
+
const quadrant = Math.round(reduced / 90);
|
|
87
|
+
const angle = angleRound_(reduced - 90 * quadrant + correction);
|
|
88
|
+
const radians = angle * DEG_TO_RAD;
|
|
89
|
+
let sine = Math.sin(radians);
|
|
90
|
+
let cosine = Math.cos(radians);
|
|
91
|
+
const magnitude = Math.abs(angle);
|
|
92
|
+
const sign = copySign(1, radians);
|
|
93
|
+
if (magnitude === 45) {
|
|
94
|
+
cosine = Math.SQRT1_2;
|
|
95
|
+
sine = sign * cosine;
|
|
96
|
+
}
|
|
97
|
+
else if (magnitude === 30) {
|
|
98
|
+
cosine = Math.sqrt(0.75);
|
|
99
|
+
sine = sign * 0.5;
|
|
100
|
+
}
|
|
101
|
+
let resultSine;
|
|
102
|
+
let resultCosine;
|
|
103
|
+
switch (quadrant & 3) {
|
|
104
|
+
case 0:
|
|
105
|
+
resultSine = sine;
|
|
106
|
+
resultCosine = cosine;
|
|
107
|
+
break;
|
|
108
|
+
case 1:
|
|
109
|
+
resultSine = cosine;
|
|
110
|
+
resultCosine = -sine;
|
|
111
|
+
break;
|
|
112
|
+
case 2:
|
|
113
|
+
resultSine = -sine;
|
|
114
|
+
resultCosine = -cosine;
|
|
115
|
+
break;
|
|
116
|
+
default:
|
|
117
|
+
resultSine = -cosine;
|
|
118
|
+
resultCosine = sine;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
resultCosine += 0;
|
|
122
|
+
const zeroSine = copySign(0, x + correction);
|
|
123
|
+
if (resultSine === 0) {
|
|
124
|
+
resultSine = zeroSine;
|
|
125
|
+
}
|
|
126
|
+
io[0] = resultSine;
|
|
127
|
+
io[1] = resultCosine;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=_angle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_angle.js","sourceRoot":"","sources":["../../src/geodesic/_angle.ts"],"names":[],"mappings":"AAAA,6IAA6I;AAE7I,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQxE,MAAM,UAAU,cAAc,CAAC,MAAc;IAC5C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAEnD,iFAAiF;AACjF,SAAS,UAAU,CAAC,CAAS,EAAE,MAAc;IAC5C,MAAM,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC;IAC3B,IAAI,OAAO,GAAG,CAAC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AC,CAAC,CAAC,GAAG,UAAU,CAAC;IACnB,EAAE,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*! Derived from GeographicLib Geodesic.js (geographiclib-geodesic 2.2.0), Copyright (c) 2011-2022, Charles Karney, MIT License — see LICENSE. */
|
|
2
|
+
import type { Ellipsoid } from "../ellipsoid.js";
|
|
3
|
+
import { type Scratch_ } from "./_angle.js";
|
|
4
|
+
/**
|
|
5
|
+
* The order of the series in the third flattening `n` (GeographicLib's default
|
|
6
|
+
* for doubles).
|
|
7
|
+
*/
|
|
8
|
+
export declare const SERIES_ORDER_ = 6;
|
|
9
|
+
/** Indices into an ellipsoid's constants. */
|
|
10
|
+
export declare const CONSTANT_EQUATORIAL_RADIUS_ = 0;
|
|
11
|
+
export declare const CONSTANT_FLATTENING_ = 1;
|
|
12
|
+
/** `1 − f`. */
|
|
13
|
+
export declare const CONSTANT_POLAR_RATIO_ = 2;
|
|
14
|
+
/** The second eccentricity squared, `e² / (1 − e²)`. */
|
|
15
|
+
export declare const CONSTANT_SECOND_ECCENTRICITY_SQUARED_ = 3;
|
|
16
|
+
/** The third flattening `n = f / (2 − f)`. */
|
|
17
|
+
export declare const CONSTANT_THIRD_FLATTENING_ = 4;
|
|
18
|
+
export declare const CONSTANT_POLAR_RADIUS_ = 5;
|
|
19
|
+
/** The arc length under which a line counts as really short. */
|
|
20
|
+
export declare const CONSTANT_SHORT_ARC_ = 6;
|
|
21
|
+
/** The `A3` series: `SERIES_ORDER_` coefficients in `eps`. */
|
|
22
|
+
export declare const CONSTANT_A3_ = 7;
|
|
23
|
+
/** The `C3` series: `C3_COUNT_` coefficients. */
|
|
24
|
+
export declare const CONSTANT_C3_: number;
|
|
25
|
+
/**
|
|
26
|
+
* Where an ellipsoid record keeps its geodesic constants: a non-enumerable
|
|
27
|
+
* property under this symbol, so a lookup is one property read.
|
|
28
|
+
*/
|
|
29
|
+
export declare const CONSTANTS_KEY_: unique symbol;
|
|
30
|
+
/**
|
|
31
|
+
* The constants of an ellipsoid of revolution the solvers read, in one
|
|
32
|
+
* `Float64Array`: the radii and ratios of the record plus the series in the
|
|
33
|
+
* third flattening, all computed once.
|
|
34
|
+
*/
|
|
35
|
+
export declare function constantsCreate_(equatorialRadius: number, flattening: number): Scratch_;
|
|
36
|
+
/** The constants an ellipsoid record carries, derived again for a copy of one. */
|
|
37
|
+
export declare function constantsOf_(ellipsoid: Ellipsoid): Scratch_;
|
|
38
|
+
//# sourceMappingURL=_constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_constants.d.ts","sourceRoot":"","sources":["../../src/geodesic/_constants.ts"],"names":[],"mappings":"AAAA,iJAAiJ;AAIjJ,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAK/B,6CAA6C;AAC7C,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAe;AACf,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,wDAAwD;AACxD,eAAO,MAAM,qCAAqC,IAAI,CAAC;AACvD,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAC5C,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,8DAA8D;AAC9D,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,iDAAiD;AACjD,eAAO,MAAM,YAAY,QAA+B,CAAC;AAGzD;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,MAAyC,CAAC;AAkD9E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,MAAM,GAChB,QAAQ,CA2CV;AAKD,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,CAgB3D"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*! Derived from GeographicLib Geodesic.js (geographiclib-geodesic 2.2.0), Copyright (c) 2011-2022, Charles Karney, MIT License — see LICENSE. */
|
|
2
|
+
import { polynomialEvaluate } from "@ac-kit/math-scalar";
|
|
3
|
+
import { scratchCreate_ } from "./_angle.js";
|
|
4
|
+
/**
|
|
5
|
+
* The order of the series in the third flattening `n` (GeographicLib's default
|
|
6
|
+
* for doubles).
|
|
7
|
+
*/
|
|
8
|
+
export const SERIES_ORDER_ = 6;
|
|
9
|
+
/** The number of coefficients of the `C3` series, `order × (order − 1) / 2`. */
|
|
10
|
+
const C3_COUNT_ = 15;
|
|
11
|
+
/** Indices into an ellipsoid's constants. */
|
|
12
|
+
export const CONSTANT_EQUATORIAL_RADIUS_ = 0;
|
|
13
|
+
export const CONSTANT_FLATTENING_ = 1;
|
|
14
|
+
/** `1 − f`. */
|
|
15
|
+
export const CONSTANT_POLAR_RATIO_ = 2;
|
|
16
|
+
/** The second eccentricity squared, `e² / (1 − e²)`. */
|
|
17
|
+
export const CONSTANT_SECOND_ECCENTRICITY_SQUARED_ = 3;
|
|
18
|
+
/** The third flattening `n = f / (2 − f)`. */
|
|
19
|
+
export const CONSTANT_THIRD_FLATTENING_ = 4;
|
|
20
|
+
export const CONSTANT_POLAR_RADIUS_ = 5;
|
|
21
|
+
/** The arc length under which a line counts as really short. */
|
|
22
|
+
export const CONSTANT_SHORT_ARC_ = 6;
|
|
23
|
+
/** The `A3` series: `SERIES_ORDER_` coefficients in `eps`. */
|
|
24
|
+
export const CONSTANT_A3_ = 7;
|
|
25
|
+
/** The `C3` series: `C3_COUNT_` coefficients. */
|
|
26
|
+
export const CONSTANT_C3_ = CONSTANT_A3_ + SERIES_ORDER_;
|
|
27
|
+
const CONSTANT_COUNT_ = CONSTANT_C3_ + C3_COUNT_;
|
|
28
|
+
/**
|
|
29
|
+
* Where an ellipsoid record keeps its geodesic constants: a non-enumerable
|
|
30
|
+
* property under this symbol, so a lookup is one property read.
|
|
31
|
+
*/
|
|
32
|
+
export const CONSTANTS_KEY_ = Symbol("math-geodesy.constants");
|
|
33
|
+
const A3_COEFFICIENTS_ = new Float64Array([
|
|
34
|
+
// A3, coeff of eps^5, polynomial in n of order 0
|
|
35
|
+
-3, 128,
|
|
36
|
+
// A3, coeff of eps^4, polynomial in n of order 1
|
|
37
|
+
-2, -3, 64,
|
|
38
|
+
// A3, coeff of eps^3, polynomial in n of order 2
|
|
39
|
+
-1, -3, -1, 16,
|
|
40
|
+
// A3, coeff of eps^2, polynomial in n of order 2
|
|
41
|
+
+3, -1, -2, 8,
|
|
42
|
+
// A3, coeff of eps^1, polynomial in n of order 1
|
|
43
|
+
+1, -1, 2,
|
|
44
|
+
// A3, coeff of eps^0, polynomial in n of order 0
|
|
45
|
+
+1, 1,
|
|
46
|
+
]);
|
|
47
|
+
const C3_COEFFICIENTS_ = new Float64Array([
|
|
48
|
+
// C3[1], coeff of eps^5, polynomial in n of order 0
|
|
49
|
+
+3, 128,
|
|
50
|
+
// C3[1], coeff of eps^4, polynomial in n of order 1
|
|
51
|
+
+2, 5, 128,
|
|
52
|
+
// C3[1], coeff of eps^3, polynomial in n of order 2
|
|
53
|
+
-1, 3, 3, 64,
|
|
54
|
+
// C3[1], coeff of eps^2, polynomial in n of order 2
|
|
55
|
+
-1, 0, 1, 8,
|
|
56
|
+
// C3[1], coeff of eps^1, polynomial in n of order 1
|
|
57
|
+
-1, 1, 4,
|
|
58
|
+
// C3[2], coeff of eps^5, polynomial in n of order 0
|
|
59
|
+
+5, 256,
|
|
60
|
+
// C3[2], coeff of eps^4, polynomial in n of order 1
|
|
61
|
+
+1, 3, 128,
|
|
62
|
+
// C3[2], coeff of eps^3, polynomial in n of order 2
|
|
63
|
+
-3, -2, 3, 64,
|
|
64
|
+
// C3[2], coeff of eps^2, polynomial in n of order 2
|
|
65
|
+
+1, -3, 2, 32,
|
|
66
|
+
// C3[3], coeff of eps^5, polynomial in n of order 0
|
|
67
|
+
+7, 512,
|
|
68
|
+
// C3[3], coeff of eps^4, polynomial in n of order 1
|
|
69
|
+
-10, 9, 384,
|
|
70
|
+
// C3[3], coeff of eps^3, polynomial in n of order 2
|
|
71
|
+
+5, -9, 5, 192,
|
|
72
|
+
// C3[4], coeff of eps^5, polynomial in n of order 0
|
|
73
|
+
+7, 512,
|
|
74
|
+
// C3[4], coeff of eps^4, polynomial in n of order 1
|
|
75
|
+
-14, 7, 512,
|
|
76
|
+
// C3[5], coeff of eps^5, polynomial in n of order 0
|
|
77
|
+
+21, 2560,
|
|
78
|
+
]);
|
|
79
|
+
/**
|
|
80
|
+
* The constants of an ellipsoid of revolution the solvers read, in one
|
|
81
|
+
* `Float64Array`: the radii and ratios of the record plus the series in the
|
|
82
|
+
* third flattening, all computed once.
|
|
83
|
+
*/
|
|
84
|
+
export function constantsCreate_(equatorialRadius, flattening) {
|
|
85
|
+
const constants = scratchCreate_(CONSTANT_COUNT_);
|
|
86
|
+
const polarRatio = 1 - flattening;
|
|
87
|
+
const eccentricitySquared = flattening * (2 - flattening);
|
|
88
|
+
const thirdFlattening = flattening / (2 - flattening);
|
|
89
|
+
constants[CONSTANT_EQUATORIAL_RADIUS_] = equatorialRadius;
|
|
90
|
+
constants[CONSTANT_FLATTENING_] = flattening;
|
|
91
|
+
constants[CONSTANT_POLAR_RATIO_] = polarRatio;
|
|
92
|
+
constants[CONSTANT_SECOND_ECCENTRICITY_SQUARED_] =
|
|
93
|
+
eccentricitySquared / (polarRatio * polarRatio);
|
|
94
|
+
constants[CONSTANT_THIRD_FLATTENING_] = thirdFlattening;
|
|
95
|
+
constants[CONSTANT_POLAR_RADIUS_] = equatorialRadius * polarRatio;
|
|
96
|
+
// The threshold below which the auxiliary-sphere solution of a short line
|
|
97
|
+
// is exact to round-off; 0.1 is a safety factor and max(0.001, |f|) keeps
|
|
98
|
+
// it bounded for a nearly spherical ellipsoid.
|
|
99
|
+
constants[CONSTANT_SHORT_ARC_] =
|
|
100
|
+
(0.1 * Math.sqrt(Number.EPSILON)) /
|
|
101
|
+
Math.sqrt((Math.max(0.001, Math.abs(flattening)) *
|
|
102
|
+
Math.min(1, 1 - flattening / 2)) /
|
|
103
|
+
2);
|
|
104
|
+
let offset = 0;
|
|
105
|
+
let index = 0;
|
|
106
|
+
for (let power = SERIES_ORDER_ - 1; power >= 0; power--) {
|
|
107
|
+
const degree = Math.min(SERIES_ORDER_ - power - 1, power);
|
|
108
|
+
constants[CONSTANT_A3_ + index++] =
|
|
109
|
+
polynomialEvaluate(A3_COEFFICIENTS_, offset, degree, thirdFlattening) /
|
|
110
|
+
A3_COEFFICIENTS_[offset + degree + 1];
|
|
111
|
+
offset += degree + 2;
|
|
112
|
+
}
|
|
113
|
+
offset = 0;
|
|
114
|
+
index = 0;
|
|
115
|
+
for (let order = 1; order < SERIES_ORDER_; order++) {
|
|
116
|
+
for (let power = SERIES_ORDER_ - 1; power >= order; power--) {
|
|
117
|
+
const degree = Math.min(SERIES_ORDER_ - power - 1, power);
|
|
118
|
+
constants[CONSTANT_C3_ + index++] =
|
|
119
|
+
polynomialEvaluate(C3_COEFFICIENTS_, offset, degree, thirdFlattening) /
|
|
120
|
+
C3_COEFFICIENTS_[offset + degree + 1];
|
|
121
|
+
offset += degree + 2;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return constants;
|
|
125
|
+
}
|
|
126
|
+
/** Constants derived for ellipsoid records that lost theirs (a copy by spread). */
|
|
127
|
+
const derived_ = new WeakMap();
|
|
128
|
+
/** The constants an ellipsoid record carries, derived again for a copy of one. */
|
|
129
|
+
export function constantsOf_(ellipsoid) {
|
|
130
|
+
const own = ellipsoid[CONSTANTS_KEY_];
|
|
131
|
+
if (own !== undefined) {
|
|
132
|
+
return own;
|
|
133
|
+
}
|
|
134
|
+
let constants = derived_.get(ellipsoid);
|
|
135
|
+
if (constants === undefined) {
|
|
136
|
+
constants = constantsCreate_(ellipsoid.semiMajorAxisM, ellipsoid.flattening);
|
|
137
|
+
derived_.set(ellipsoid, constants);
|
|
138
|
+
}
|
|
139
|
+
return constants;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=_constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_constants.js","sourceRoot":"","sources":["../../src/geodesic/_constants.ts"],"names":[],"mappings":"AAAA,iJAAiJ;AAEjJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAiB,MAAM,aAAa,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,gFAAgF;AAChF,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACtC,eAAe;AACf,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,wDAAwD;AACxD,MAAM,CAAC,MAAM,qCAAqC,GAAG,CAAC,CAAC;AACvD,8CAA8C;AAC9C,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACxC,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,iDAAiD;AACjD,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC;AACzD,MAAM,eAAe,GAAG,YAAY,GAAG,SAAS,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB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AAC,SAAoB;IAChD,MAAM,GAAG,GAAI,SAAwD,CACpE,cAAc,CACd,CAAC;IACF,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,IAAI,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC7B,SAAS,GAAG,gBAAgB,CAC3B,SAAS,CAAC,cAAc,EACxB,SAAS,CAAC,UAAU,CACpB,CAAC;QACF,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*! Derived from GeographicLib Geodesic.js (geographiclib-geodesic 2.2.0), Copyright (c) 2011-2022, Charles Karney, MIT License — see LICENSE. */
|
|
2
|
+
import { type Scratch_ } from "./_angle.js";
|
|
3
|
+
/** The indices of the input and the result of {@link inverse_}. */
|
|
4
|
+
export declare const INVERSE_LATITUDE1_ = 0;
|
|
5
|
+
export declare const INVERSE_LONGITUDE1_ = 1;
|
|
6
|
+
export declare const INVERSE_LATITUDE2_ = 2;
|
|
7
|
+
export declare const INVERSE_LONGITUDE2_ = 3;
|
|
8
|
+
export declare const INVERSE_DISTANCE_ = 0;
|
|
9
|
+
export declare const INVERSE_SIN_ALPHA1_ = 1;
|
|
10
|
+
export declare const INVERSE_COS_ALPHA1_ = 2;
|
|
11
|
+
export declare const INVERSE_SIN_ALPHA2_ = 3;
|
|
12
|
+
export declare const INVERSE_COS_ALPHA2_ = 4;
|
|
13
|
+
export declare const INVERSE_LENGTH_ = 5;
|
|
14
|
+
/**
|
|
15
|
+
* Solves the inverse problem between `(latitude1, longitude1)` and `(latitude2,
|
|
16
|
+
* longitude2)`, degrees, read from `io[0 … 3]`; `io` then holds the distance in
|
|
17
|
+
* metres and the sine and cosine of both azimuths. A latitude beyond ±90° and
|
|
18
|
+
* non-finite input give `NaN`s. (One buffer in and out: a call passing doubles
|
|
19
|
+
* as arguments would box them.)
|
|
20
|
+
*/
|
|
21
|
+
export declare function inverse_(constants: Scratch_, io: Scratch_): void;
|
|
22
|
+
//# sourceMappingURL=_inverse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_inverse.d.ts","sourceRoot":"","sources":["../../src/geodesic/_inverse.ts"],"names":[],"mappings":"AAAA,iJAAiJ;AAcjJ,OAAO,EAGN,KAAK,QAAQ,EAKb,MAAM,aAAa,CAAC;AAwdrB,mEAAmE;AACnE,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,GAAG,IAAI,CAuRhE"}
|