@math.gl/geospatial 3.6.0-alpha.1 → 3.6.0-alpha.2
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/dist/ellipsoid/ellipsoid.d.ts.map +1 -1
- package/dist/ellipsoid/ellipsoid.js +11 -1
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts +4 -1
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts.map +1 -1
- package/dist/ellipsoid/helpers/ellipsoid-transform.js +2 -1
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.d.ts +2 -2
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.d.ts.map +1 -1
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.js +5 -5
- package/dist/es5/constants.js +4 -4
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/ellipsoid/ellipsoid.js +152 -109
- package/dist/es5/ellipsoid/ellipsoid.js.map +1 -1
- package/dist/es5/ellipsoid/helpers/ellipsoid-transform.js +21 -25
- package/dist/es5/ellipsoid/helpers/ellipsoid-transform.js.map +1 -1
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js +38 -39
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/es5/index.js +2 -2
- package/dist/es5/type-utils.js +36 -29
- package/dist/es5/type-utils.js.map +1 -1
- package/dist/esm/ellipsoid/ellipsoid.js +1 -1
- package/dist/esm/ellipsoid/ellipsoid.js.map +1 -1
- package/dist/esm/ellipsoid/helpers/ellipsoid-transform.js.map +1 -1
- package/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js +5 -5
- package/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/esm/type-utils.js +22 -20
- package/dist/esm/type-utils.js.map +1 -1
- package/dist/type-utils.d.ts +5 -5
- package/dist/type-utils.d.ts.map +1 -1
- package/dist/type-utils.js +24 -22
- package/package.json +4 -4
- package/src/ellipsoid/ellipsoid.ts +8 -13
- package/src/ellipsoid/helpers/ellipsoid-transform.ts +18 -13
- package/src/ellipsoid/helpers/scale-to-geodetic-surface.ts +11 -7
- package/src/type-utils.ts +45 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ellipsoid.d.ts","sourceRoot":"","sources":["../../src/ellipsoid/ellipsoid.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,OAAO,EAMP,YAAY,EACb,MAAM,eAAe,CAAC;AAkBvB;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"ellipsoid.d.ts","sourceRoot":"","sources":["../../src/ellipsoid/ellipsoid.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,OAAO,EAMP,YAAY,EACb,MAAM,eAAe,CAAC;AAkBvB;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAiE;IAEjG,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAuB;IAC9D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IAEtC,4FAA4F;gBAChF,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;;IAqC3C,2EAA2E;IAC3E,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QAAQ,GAAG,QAAQ;IAKlF,qGAAqG;IACrG,iCAAiC,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ;IAC/F,iCAAiC,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAgBnE,yGAAyG;IACzG,qBAAqB,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS;IACnF,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAKpD;;0EAEsE;IACtE,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAIxE;yDACqD;IACrD,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAmBrF;kEAC8D;IAC9D,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAI1F;4DACwD;IACxD,gCAAgC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAI5F,wFAAwF;IACxF,qCAAqC,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAM,EAAc,GAC3B,MAAM,EAAE;CAcZ"}
|
|
@@ -95,9 +95,14 @@ export default class Ellipsoid {
|
|
|
95
95
|
geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
96
96
|
return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
|
|
97
97
|
}
|
|
98
|
+
/** Scales the provided Cartesian position along the geodetic surface normal
|
|
99
|
+
* so that it is on the surface of this ellipsoid. If the position is
|
|
100
|
+
* at the center of the ellipsoid, this function returns undefined. */
|
|
98
101
|
scaleToGeodeticSurface(cartesian, result) {
|
|
99
102
|
return scaleToGeodeticSurface(cartesian, this, result);
|
|
100
103
|
}
|
|
104
|
+
/** Scales the provided Cartesian position along the geocentric surface normal
|
|
105
|
+
* so that it is on the surface of this ellipsoid. */
|
|
101
106
|
scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {
|
|
102
107
|
scratchPosition.from(cartesian);
|
|
103
108
|
const positionX = scratchPosition.x;
|
|
@@ -110,13 +115,18 @@ export default class Ellipsoid {
|
|
|
110
115
|
positionZ * positionZ * oneOverRadiiSquared.z);
|
|
111
116
|
return scratchPosition.multiplyScalar(beta).to(result);
|
|
112
117
|
}
|
|
118
|
+
/** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
|
|
119
|
+
* its components by the result of `Ellipsoid#oneOverRadii` */
|
|
113
120
|
transformPositionToScaledSpace(position, result = [0, 0, 0]) {
|
|
114
121
|
return scratchPosition.from(position).scale(this.oneOverRadii).to(result);
|
|
115
122
|
}
|
|
123
|
+
/** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
|
|
124
|
+
* its components by the result of `Ellipsoid#radii`. */
|
|
116
125
|
transformPositionFromScaledSpace(position, result = [0, 0, 0]) {
|
|
117
126
|
return scratchPosition.from(position).scale(this.radii).to(result);
|
|
118
127
|
}
|
|
119
|
-
|
|
128
|
+
/** Computes a point which is the intersection of the surface normal with the z-axis. */
|
|
129
|
+
getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {
|
|
120
130
|
// Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)
|
|
121
131
|
assert(equals(this.radii.x, this.radii.y, _MathUtils.EPSILON15));
|
|
122
132
|
assert(this.radii.z > 0);
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type Ellipsoid from '../ellipsoid';
|
|
2
|
+
declare type Axis = 'up' | 'down' | 'north' | 'east' | 'south' | 'west';
|
|
3
|
+
export default function localFrameToFixedFrame(ellipsoid: Ellipsoid, firstAxis: Axis, secondAxis: Axis, thirdAxis: Axis, cartesianOrigin: number[], result: number[]): number[];
|
|
4
|
+
export {};
|
|
2
5
|
//# sourceMappingURL=ellipsoid-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ellipsoid-transform.d.ts","sourceRoot":"","sources":["../../../src/ellipsoid/helpers/ellipsoid-transform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ellipsoid-transform.d.ts","sourceRoot":"","sources":["../../../src/ellipsoid/helpers/ellipsoid-transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAoE1C,aAAK,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAKhE,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,IAAI,EACf,UAAU,EAAE,IAAI,EAChB,SAAS,EAAE,IAAI,EACf,eAAe,EAAE,MAAM,EAAE,EACzB,MAAM,EAAE,MAAM,EAAE,GACf,MAAM,EAAE,CAwEV"}
|
|
@@ -63,7 +63,8 @@ const scratchVector3 = new Vector3();
|
|
|
63
63
|
// centered at the provided origin to the provided ellipsoid's fixed reference frame.
|
|
64
64
|
// eslint-disable-next-line max-statements, max-params, complexity
|
|
65
65
|
export default function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, cartesianOrigin, result) {
|
|
66
|
-
const thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] &&
|
|
66
|
+
const thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] &&
|
|
67
|
+
VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];
|
|
67
68
|
// firstAxis and secondAxis must be east, north, up, west, south or down.');
|
|
68
69
|
assert(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));
|
|
69
70
|
let firstAxisVector;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default function scaleToGeodeticSurface(cartesian:
|
|
1
|
+
import type Ellipsoid from '../ellipsoid';
|
|
2
|
+
export default function scaleToGeodeticSurface(cartesian: number[], ellipsoid: Ellipsoid, result?: number[]): number[];
|
|
3
3
|
//# sourceMappingURL=scale-to-geodetic-surface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale-to-geodetic-surface.d.ts","sourceRoot":"","sources":["../../../src/ellipsoid/helpers/scale-to-geodetic-surface.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scale-to-geodetic-surface.d.ts","sourceRoot":"","sources":["../../../src/ellipsoid/helpers/scale-to-geodetic-surface.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAS1C,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,SAAS,EAAE,MAAM,EAAE,EACnB,SAAS,EAAE,SAAS,EACpB,MAAM,GAAE,MAAM,EAAO,GACpB,MAAM,EAAE,CAuFV"}
|
|
@@ -6,12 +6,12 @@ const scaleToGeodeticSurfaceGradient = new Vector3();
|
|
|
6
6
|
// Scales the provided Cartesian position along the geodetic surface normal
|
|
7
7
|
// so that it is on the surface of this ellipsoid. If the position is
|
|
8
8
|
// at the center of the ellipsoid, this function returns undefined.
|
|
9
|
-
export default function scaleToGeodeticSurface(cartesian, ellipsoid, result =
|
|
9
|
+
export default function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
|
|
10
10
|
const { oneOverRadii, oneOverRadiiSquared, centerToleranceSquared } = ellipsoid;
|
|
11
11
|
scratchVector.from(cartesian);
|
|
12
|
-
const positionX =
|
|
13
|
-
const positionY =
|
|
14
|
-
const positionZ =
|
|
12
|
+
const positionX = scratchVector.x;
|
|
13
|
+
const positionY = scratchVector.y;
|
|
14
|
+
const positionZ = scratchVector.z;
|
|
15
15
|
const oneOverRadiiX = oneOverRadii.x;
|
|
16
16
|
const oneOverRadiiY = oneOverRadii.y;
|
|
17
17
|
const oneOverRadiiZ = oneOverRadii.z;
|
|
@@ -40,7 +40,7 @@ export default function scaleToGeodeticSurface(cartesian, ellipsoid, result = ne
|
|
|
40
40
|
const gradient = scaleToGeodeticSurfaceGradient;
|
|
41
41
|
gradient.set(intersection.x * oneOverRadiiSquaredX * 2.0, intersection.y * oneOverRadiiSquaredY * 2.0, intersection.z * oneOverRadiiSquaredZ * 2.0);
|
|
42
42
|
// Compute the initial guess at the normal vector multiplier, lambda.
|
|
43
|
-
let lambda = ((1.0 - ratio) *
|
|
43
|
+
let lambda = ((1.0 - ratio) * scratchVector.len()) / (0.5 * gradient.len());
|
|
44
44
|
let correction = 0.0;
|
|
45
45
|
let xMultiplier;
|
|
46
46
|
let yMultiplier;
|
package/dist/es5/constants.js
CHANGED
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.WGS84_CONSTANTS = exports.WGS84_RADIUS_Z = exports.WGS84_RADIUS_Y = exports.WGS84_RADIUS_X = void 0;
|
|
7
|
-
|
|
7
|
+
var WGS84_RADIUS_X = 6378137.0;
|
|
8
8
|
exports.WGS84_RADIUS_X = WGS84_RADIUS_X;
|
|
9
|
-
|
|
9
|
+
var WGS84_RADIUS_Y = 6378137.0;
|
|
10
10
|
exports.WGS84_RADIUS_Y = WGS84_RADIUS_Y;
|
|
11
|
-
|
|
11
|
+
var WGS84_RADIUS_Z = 6356752.3142451793;
|
|
12
12
|
exports.WGS84_RADIUS_Z = WGS84_RADIUS_Z;
|
|
13
|
-
|
|
13
|
+
var WGS84_CONSTANTS = {
|
|
14
14
|
radii: [WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z],
|
|
15
15
|
radiiSquared: [WGS84_RADIUS_X * WGS84_RADIUS_X, WGS84_RADIUS_Y * WGS84_RADIUS_Y, WGS84_RADIUS_Z * WGS84_RADIUS_Z],
|
|
16
16
|
oneOverRadii: [1.0 / WGS84_RADIUS_X, 1.0 / WGS84_RADIUS_Y, 1.0 / WGS84_RADIUS_Z],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants.ts"],"names":["WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","WGS84_CONSTANTS","radii","radiiSquared","oneOverRadii","oneOverRadiiSquared","maximumRadius","Math","max","centerToleranceSquared"],"mappings":";;;;;;AAGO,
|
|
1
|
+
{"version":3,"sources":["../../src/constants.ts"],"names":["WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","WGS84_CONSTANTS","radii","radiiSquared","oneOverRadii","oneOverRadiiSquared","maximumRadius","Math","max","centerToleranceSquared"],"mappings":";;;;;;AAGO,IAAMA,cAAc,GAAG,SAAvB;;AACA,IAAMC,cAAc,GAAG,SAAvB;;AACA,IAAMC,cAAc,GAAG,kBAAvB;;AAIA,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,KAAK,EAAE,CAACJ,cAAD,EAAiBC,cAAjB,EAAiCC,cAAjC,CADsB;AAE7BG,EAAAA,YAAY,EAAE,CACZL,cAAc,GAAGA,cADL,EAEZC,cAAc,GAAGA,cAFL,EAGZC,cAAc,GAAGA,cAHL,CAFe;AAO7BI,EAAAA,YAAY,EAAE,CAAC,MAAMN,cAAP,EAAuB,MAAMC,cAA7B,EAA6C,MAAMC,cAAnD,CAPe;AAQ7BK,EAAAA,mBAAmB,EAAE,CACnB,OAAOP,cAAc,GAAGA,cAAxB,CADmB,EAEnB,OAAOC,cAAc,GAAGA,cAAxB,CAFmB,EAGnB,OAAOC,cAAc,GAAGA,cAAxB,CAHmB,CARQ;AAa7BM,EAAAA,aAAa,EAAEC,IAAI,CAACC,GAAL,CAASV,cAAT,EAAyBC,cAAzB,EAAyCC,cAAzC,CAbc;AAc7BS,EAAAA,sBAAsB,EAAE;AAdK,CAAxB","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nexport const WGS84_RADIUS_X = 6378137.0;\nexport const WGS84_RADIUS_Y = 6378137.0;\nexport const WGS84_RADIUS_Z = 6356752.3142451793;\n\n// Pre-calculated ellipsoid defaults to avoid utils depending on `ellipsoid.js`\n\nexport const WGS84_CONSTANTS = {\n radii: [WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z],\n radiiSquared: [\n WGS84_RADIUS_X * WGS84_RADIUS_X,\n WGS84_RADIUS_Y * WGS84_RADIUS_Y,\n WGS84_RADIUS_Z * WGS84_RADIUS_Z\n ],\n oneOverRadii: [1.0 / WGS84_RADIUS_X, 1.0 / WGS84_RADIUS_Y, 1.0 / WGS84_RADIUS_Z],\n oneOverRadiiSquared: [\n 1.0 / (WGS84_RADIUS_X * WGS84_RADIUS_X),\n 1.0 / (WGS84_RADIUS_Y * WGS84_RADIUS_Y),\n 1.0 / (WGS84_RADIUS_Z * WGS84_RADIUS_Z)\n ],\n maximumRadius: Math.max(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z),\n centerToleranceSquared: 1e-1 // EPSILON1;\n};\n"],"file":"constants.js"}
|
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports.default = void 0;
|
|
9
11
|
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
10
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
19
|
|
|
12
20
|
var _core = require("@math.gl/core");
|
|
@@ -17,24 +25,28 @@ var _constants = require("../constants");
|
|
|
17
25
|
|
|
18
26
|
var _typeUtils = require("../type-utils");
|
|
19
27
|
|
|
20
|
-
var
|
|
28
|
+
var _scaleToGeodeticSurface2 = _interopRequireDefault(require("./helpers/scale-to-geodetic-surface"));
|
|
21
29
|
|
|
22
30
|
var _ellipsoidTransform = _interopRequireDefault(require("./helpers/ellipsoid-transform"));
|
|
23
31
|
|
|
24
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
33
|
|
|
26
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
var scratchVector = new _core.Vector3();
|
|
37
|
+
var scratchNormal = new _core.Vector3();
|
|
38
|
+
var scratchK = new _core.Vector3();
|
|
39
|
+
var scratchPosition = new _core.Vector3();
|
|
40
|
+
var scratchHeight = new _core.Vector3();
|
|
41
|
+
var scratchCartesian = new _core.Vector3();
|
|
42
|
+
var wgs84;
|
|
35
43
|
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
var Ellipsoid = function () {
|
|
45
|
+
function Ellipsoid() {
|
|
46
|
+
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.0;
|
|
47
|
+
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.0;
|
|
48
|
+
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.0;
|
|
49
|
+
(0, _classCallCheck2.default)(this, Ellipsoid);
|
|
38
50
|
(0, _defineProperty2.default)(this, "radii", void 0);
|
|
39
51
|
(0, _defineProperty2.default)(this, "radiiSquared", void 0);
|
|
40
52
|
(0, _defineProperty2.default)(this, "radiiToTheFourth", void 0);
|
|
@@ -62,105 +74,136 @@ class Ellipsoid {
|
|
|
62
74
|
Object.freeze(this);
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
toString() {
|
|
70
|
-
return this.radii.toString();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
cartographicToCartesian(cartographic, result = [0, 0, 0]) {
|
|
74
|
-
const normal = scratchNormal;
|
|
75
|
-
const k = scratchK;
|
|
76
|
-
const [,, height] = cartographic;
|
|
77
|
-
this.geodeticSurfaceNormalCartographic(cartographic, normal);
|
|
78
|
-
k.copy(this.radiiSquared).scale(normal);
|
|
79
|
-
const gamma = Math.sqrt(normal.dot(k));
|
|
80
|
-
k.scale(1 / gamma);
|
|
81
|
-
normal.scale(height);
|
|
82
|
-
k.add(normal);
|
|
83
|
-
return k.to(result);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
cartesianToCartographic(cartesian, result = [0, 0, 0]) {
|
|
87
|
-
scratchCartesian.from(cartesian);
|
|
88
|
-
const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);
|
|
89
|
-
|
|
90
|
-
if (!point) {
|
|
91
|
-
return undefined;
|
|
77
|
+
(0, _createClass2.default)(Ellipsoid, [{
|
|
78
|
+
key: "equals",
|
|
79
|
+
value: function equals(right) {
|
|
80
|
+
return this === right || Boolean(right && this.radii.equals(right.radii));
|
|
92
81
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const longitude = Math.atan2(normal.y, normal.x);
|
|
98
|
-
const latitude = Math.asin(normal.z);
|
|
99
|
-
const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);
|
|
100
|
-
return (0, _typeUtils.toCartographicFromRadians)([longitude, latitude, height], result);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
eastNorthUpToFixedFrame(origin, result = new _core.Matrix4()) {
|
|
104
|
-
return (0, _ellipsoidTransform.default)(this, 'east', 'north', 'up', origin, result);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new _core.Matrix4()) {
|
|
108
|
-
return (0, _ellipsoidTransform.default)(this, firstAxis, secondAxis, thirdAxis, origin, result);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
112
|
-
return scratchVector.from(cartesian).normalize().to(result);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {
|
|
116
|
-
const cartographicVectorRadians = (0, _typeUtils.fromCartographicToRadians)(cartographic);
|
|
117
|
-
const longitude = cartographicVectorRadians[0];
|
|
118
|
-
const latitude = cartographicVectorRadians[1];
|
|
119
|
-
const cosLatitude = Math.cos(latitude);
|
|
120
|
-
scratchVector.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude)).normalize();
|
|
121
|
-
return scratchVector.to(result);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
125
|
-
return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
scaleToGeodeticSurface(cartesian, result) {
|
|
129
|
-
return (0, _scaleToGeodeticSurface.default)(cartesian, this, result);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {
|
|
133
|
-
scratchPosition.from(cartesian);
|
|
134
|
-
const positionX = scratchPosition.x;
|
|
135
|
-
const positionY = scratchPosition.y;
|
|
136
|
-
const positionZ = scratchPosition.z;
|
|
137
|
-
const oneOverRadiiSquared = this.oneOverRadiiSquared;
|
|
138
|
-
const beta = 1.0 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
|
|
139
|
-
return scratchPosition.multiplyScalar(beta).to(result);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
transformPositionToScaledSpace(position, result = [0, 0, 0]) {
|
|
143
|
-
return scratchPosition.from(position).scale(this.oneOverRadii).to(result);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
transformPositionFromScaledSpace(position, result = [0, 0, 0]) {
|
|
147
|
-
return scratchPosition.from(position).scale(this.radii).to(result);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
getSurfaceNormalIntersectionWithZAxis(position, buffer = 0.0, result = [0, 0, 0]) {
|
|
151
|
-
(0, _core.assert)((0, _core.equals)(this.radii.x, this.radii.y, _core._MathUtils.EPSILON15));
|
|
152
|
-
(0, _core.assert)(this.radii.z > 0);
|
|
153
|
-
scratchPosition.from(position);
|
|
154
|
-
const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);
|
|
155
|
-
|
|
156
|
-
if (Math.abs(z) >= this.radii.z - buffer) {
|
|
157
|
-
return undefined;
|
|
82
|
+
}, {
|
|
83
|
+
key: "toString",
|
|
84
|
+
value: function toString() {
|
|
85
|
+
return this.radii.toString();
|
|
158
86
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
87
|
+
}, {
|
|
88
|
+
key: "cartographicToCartesian",
|
|
89
|
+
value: function cartographicToCartesian(cartographic) {
|
|
90
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
91
|
+
var normal = scratchNormal;
|
|
92
|
+
var k = scratchK;
|
|
93
|
+
|
|
94
|
+
var _cartographic = (0, _slicedToArray2.default)(cartographic, 3),
|
|
95
|
+
height = _cartographic[2];
|
|
96
|
+
|
|
97
|
+
this.geodeticSurfaceNormalCartographic(cartographic, normal);
|
|
98
|
+
k.copy(this.radiiSquared).scale(normal);
|
|
99
|
+
var gamma = Math.sqrt(normal.dot(k));
|
|
100
|
+
k.scale(1 / gamma);
|
|
101
|
+
normal.scale(height);
|
|
102
|
+
k.add(normal);
|
|
103
|
+
return k.to(result);
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: "cartesianToCartographic",
|
|
107
|
+
value: function cartesianToCartographic(cartesian) {
|
|
108
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
109
|
+
scratchCartesian.from(cartesian);
|
|
110
|
+
var point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);
|
|
111
|
+
|
|
112
|
+
if (!point) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var normal = this.geodeticSurfaceNormal(point, scratchNormal);
|
|
117
|
+
var h = scratchHeight;
|
|
118
|
+
h.copy(scratchCartesian).subtract(point);
|
|
119
|
+
var longitude = Math.atan2(normal.y, normal.x);
|
|
120
|
+
var latitude = Math.asin(normal.z);
|
|
121
|
+
var height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);
|
|
122
|
+
return (0, _typeUtils.toCartographicFromRadians)([longitude, latitude, height], result);
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
key: "eastNorthUpToFixedFrame",
|
|
126
|
+
value: function eastNorthUpToFixedFrame(origin) {
|
|
127
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _core.Matrix4();
|
|
128
|
+
return (0, _ellipsoidTransform.default)(this, 'east', 'north', 'up', origin, result);
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "localFrameToFixedFrame",
|
|
132
|
+
value: function localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin) {
|
|
133
|
+
var result = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _core.Matrix4();
|
|
134
|
+
return (0, _ellipsoidTransform.default)(this, firstAxis, secondAxis, thirdAxis, origin, result);
|
|
135
|
+
}
|
|
136
|
+
}, {
|
|
137
|
+
key: "geocentricSurfaceNormal",
|
|
138
|
+
value: function geocentricSurfaceNormal(cartesian) {
|
|
139
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
140
|
+
return scratchVector.from(cartesian).normalize().to(result);
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "geodeticSurfaceNormalCartographic",
|
|
144
|
+
value: function geodeticSurfaceNormalCartographic(cartographic) {
|
|
145
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
146
|
+
var cartographicVectorRadians = (0, _typeUtils.fromCartographicToRadians)(cartographic);
|
|
147
|
+
var longitude = cartographicVectorRadians[0];
|
|
148
|
+
var latitude = cartographicVectorRadians[1];
|
|
149
|
+
var cosLatitude = Math.cos(latitude);
|
|
150
|
+
scratchVector.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude)).normalize();
|
|
151
|
+
return scratchVector.to(result);
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "geodeticSurfaceNormal",
|
|
155
|
+
value: function geodeticSurfaceNormal(cartesian) {
|
|
156
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
157
|
+
return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
|
|
158
|
+
}
|
|
159
|
+
}, {
|
|
160
|
+
key: "scaleToGeodeticSurface",
|
|
161
|
+
value: function scaleToGeodeticSurface(cartesian, result) {
|
|
162
|
+
return (0, _scaleToGeodeticSurface2.default)(cartesian, this, result);
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
key: "scaleToGeocentricSurface",
|
|
166
|
+
value: function scaleToGeocentricSurface(cartesian) {
|
|
167
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
168
|
+
scratchPosition.from(cartesian);
|
|
169
|
+
var positionX = scratchPosition.x;
|
|
170
|
+
var positionY = scratchPosition.y;
|
|
171
|
+
var positionZ = scratchPosition.z;
|
|
172
|
+
var oneOverRadiiSquared = this.oneOverRadiiSquared;
|
|
173
|
+
var beta = 1.0 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
|
|
174
|
+
return scratchPosition.multiplyScalar(beta).to(result);
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "transformPositionToScaledSpace",
|
|
178
|
+
value: function transformPositionToScaledSpace(position) {
|
|
179
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
180
|
+
return scratchPosition.from(position).scale(this.oneOverRadii).to(result);
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "transformPositionFromScaledSpace",
|
|
184
|
+
value: function transformPositionFromScaledSpace(position) {
|
|
185
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
186
|
+
return scratchPosition.from(position).scale(this.radii).to(result);
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "getSurfaceNormalIntersectionWithZAxis",
|
|
190
|
+
value: function getSurfaceNormalIntersectionWithZAxis(position) {
|
|
191
|
+
var buffer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
192
|
+
var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [0, 0, 0];
|
|
193
|
+
(0, _core.assert)((0, _core.equals)(this.radii.x, this.radii.y, _core._MathUtils.EPSILON15));
|
|
194
|
+
(0, _core.assert)(this.radii.z > 0);
|
|
195
|
+
scratchPosition.from(position);
|
|
196
|
+
var z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);
|
|
197
|
+
|
|
198
|
+
if (Math.abs(z) >= this.radii.z - buffer) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return scratchPosition.set(0.0, 0.0, z).to(result);
|
|
203
|
+
}
|
|
204
|
+
}]);
|
|
205
|
+
return Ellipsoid;
|
|
206
|
+
}();
|
|
164
207
|
|
|
165
208
|
exports.default = Ellipsoid;
|
|
166
209
|
(0, _defineProperty2.default)(Ellipsoid, "WGS84", new Ellipsoid(_constants.WGS84_RADIUS_X, _constants.WGS84_RADIUS_Y, _constants.WGS84_RADIUS_Z));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ellipsoid/ellipsoid.ts"],"names":["scratchVector","Vector3","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","wgs84","Ellipsoid","constructor","x","y","z","_MathUtils","EPSILON1","radii","radiiSquared","radiiToTheFourth","oneOverRadii","oneOverRadiiSquared","minimumRadius","Math","min","maximumRadius","max","squaredXOverSquaredZ","Object","freeze","equals","right","Boolean","toString","cartographicToCartesian","cartographic","result","normal","k","height","geodeticSurfaceNormalCartographic","copy","scale","gamma","sqrt","dot","add","to","cartesianToCartographic","cartesian","from","point","scaleToGeodeticSurface","undefined","geodeticSurfaceNormal","h","subtract","longitude","atan2","latitude","asin","sign","vec3","length","eastNorthUpToFixedFrame","origin","Matrix4","localFrameToFixedFrame","firstAxis","secondAxis","thirdAxis","geocentricSurfaceNormal","normalize","cartographicVectorRadians","cosLatitude","cos","set","sin","scaleToGeocentricSurface","positionX","positionY","positionZ","beta","multiplyScalar","transformPositionToScaledSpace","position","transformPositionFromScaledSpace","getSurfaceNormalIntersectionWithZAxis","buffer","EPSILON15","abs","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z"],"mappings":";;;;;;;;;;;AAIA;;AAUA;;AAEA;;AACA;;AAEA;;AACA;;;;;;AAEA,MAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,MAAMC,aAAa,GAAG,IAAID,aAAJ,EAAtB;AACA,MAAME,QAAQ,GAAG,IAAIF,aAAJ,EAAjB;AACA,MAAMG,eAAe,GAAG,IAAIH,aAAJ,EAAxB;AACA,MAAMI,aAAa,GAAG,IAAIJ,aAAJ,EAAtB;AACA,MAAMK,gBAAgB,GAAG,IAAIL,aAAJ,EAAzB;AAEA,IAAIM,KAAJ;;AAOe,MAAMC,SAAN,CAAgB;AAkB7BC,EAAAA,WAAW,CAACC,CAAC,GAAG,GAAL,EAAUC,CAAC,GAAG,GAAd,EAAmBC,CAAC,GAAG,GAAvB,EAA4B;A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EAAiD8B,EAAjD,CAAoDX,MAApD,CAAP;AACD;;AAQDmD,EAAAA,qCAAqC,CAACF,QAAD,EAAWG,MAAM,GAAG,GAApB,EAAyBpD,MAAM,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAlC,EAA6C;AAEhF,sBAAO,kBAAO,KAAKnB,KAAL,CAAWL,CAAlB,EAAqB,KAAKK,KAAL,CAAWJ,CAAhC,EAAmCE,iBAAW0E,SAA9C,CAAP;AACA,sBAAO,KAAKxE,KAAL,CAAWH,CAAX,GAAe,CAAtB;AAEAR,IAAAA,eAAe,CAAC4C,IAAhB,CAAqBmC,QAArB;AACA,UAAMvE,CAAC,GAAGR,eAAe,CAACQ,CAAhB,IAAqB,IAAI,KAAKa,oBAA9B,CAAV;;AAEA,QAAIJ,IAAI,CAACmE,GAAL,CAAS5E,CAAT,KAAe,KAAKG,KAAL,CAAWH,CAAX,GAAe0E,MAAlC,EAA0C;AACxC,aAAOnC,SAAP;AACD;;AAED,WAAO/C,eAAe,CAACsE,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8B9D,CAA9B,EAAiCiC,EAAjC,CAAoCX,MAApC,CAAP;AACD;;AA9O4B;;;8BAAV1B,S,WAEK,IAAIA,SAAJ,CAAciF,yBAAd,EAA8BC,yBAA9B,EAA8CC,yBAA9C,C","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {\n Vector3,\n Matrix4,\n toRadians,\n toDegrees,\n assert,\n equals,\n _MathUtils,\n NumericArray\n} from '@math.gl/core';\nimport * as vec3 from 'gl-matrix/vec3';\n\nimport {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';\nimport {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';\n\nimport scaleToGeodeticSurface from './helpers/scale-to-geodetic-surface';\nimport localFrameToFixedFrame from './helpers/ellipsoid-transform';\n\nconst scratchVector = new Vector3();\nconst scratchNormal = new Vector3();\nconst scratchK = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchHeight = new Vector3();\nconst scratchCartesian = new Vector3();\n\nlet wgs84;\n\n/**\n * A quadratic surface defined in Cartesian coordinates by the equation\n * `(x / a)^2 + (y / b)^2 + (z / c)^2 = 1`. Primarily used\n * to represent the shape of planetary bodies.\n */\nexport default class Ellipsoid {\n /** An Ellipsoid instance initialized to the WGS84 standard. */\n static readonly WGS84 = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);\n\n readonly radii: Vector3;\n readonly radiiSquared: Vector3;\n readonly radiiToTheFourth: Vector3;\n readonly oneOverRadii: Vector3;\n readonly oneOverRadiiSquared: Vector3;\n readonly minimumRadius: number;\n readonly maximumRadius: number;\n readonly centerToleranceSquared: number = _MathUtils.EPSILON1;\n readonly squaredXOverSquaredZ: number;\n\n /** Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions. */\n constructor(x: number, y: number, z: number);\n constructor();\n\n constructor(x = 0.0, y = 0.0, z = 0.0) {\n assert(x >= 0.0);\n assert(y >= 0.0);\n assert(z >= 0.0);\n\n this.radii = new Vector3(x, y, z);\n\n this.radiiSquared = new Vector3(x * x, y * y, z * z);\n\n this.radiiToTheFourth = new Vector3(x * x * x * x, y * y * y * y, z * z * z * z);\n\n this.oneOverRadii = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / x,\n y === 0.0 ? 0.0 : 1.0 / y,\n z === 0.0 ? 0.0 : 1.0 / z\n );\n\n this.oneOverRadiiSquared = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / (x * x),\n y === 0.0 ? 0.0 : 1.0 / (y * y),\n z === 0.0 ? 0.0 : 1.0 / (z * z)\n );\n\n this.minimumRadius = Math.min(x, y, z);\n\n this.maximumRadius = Math.max(x, y, z);\n\n if (this.radiiSquared.z !== 0) {\n this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;\n }\n\n Object.freeze(this);\n }\n\n /** Compares this Ellipsoid against the provided Ellipsoid componentwise */\n equals(right: Ellipsoid): boolean {\n return this === right || Boolean(right && this.radii.equals(right.radii));\n }\n\n /** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */\n toString(): string {\n return this.radii.toString();\n }\n\n /** Converts the provided cartographic to Cartesian representation. */\n cartographicToCartesian(cartographic: number[], result: Vector3): Vector3;\n cartographicToCartesian(cartographic: number[], result?: number[]): number[];\n\n cartographicToCartesian(cartographic, result = [0, 0, 0]) {\n const normal = scratchNormal;\n const k = scratchK;\n\n const [, , height] = cartographic;\n this.geodeticSurfaceNormalCartographic(cartographic, normal);\n k.copy(this.radiiSquared).scale(normal);\n\n const gamma = Math.sqrt(normal.dot(k));\n k.scale(1 / gamma);\n\n normal.scale(height);\n\n k.add(normal);\n\n return k.to(result);\n }\n\n /** Converts the provided cartesian to cartographic (lng/lat/z) representation.\n * The cartesian is undefined at the center of the ellipsoid. */\n cartesianToCartographic(cartesian: number[], result: Vector3): Vector3;\n cartesianToCartographic(cartesian: number[], result?: number[]): number[];\n\n cartesianToCartographic(cartesian, result = [0, 0, 0]) {\n scratchCartesian.from(cartesian);\n const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);\n\n if (!point) {\n return undefined;\n }\n\n const normal = this.geodeticSurfaceNormal(point, scratchNormal);\n\n const h = scratchHeight;\n h.copy(scratchCartesian).subtract(point);\n\n const longitude = Math.atan2(normal.y, normal.x);\n const latitude = Math.asin(normal.z);\n const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);\n\n return toCartographicFromRadians([longitude, latitude, height], result);\n }\n\n /** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes\n * centered at the provided origin to the provided ellipsoid's fixed reference frame. */\n eastNorthUpToFixedFrame(origin: number[], result?: Matrix4): Matrix4;\n eastNorthUpToFixedFrame(origin: number[], result: number[]): number[];\n\n eastNorthUpToFixedFrame(origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, 'east', 'north', 'up', origin, result);\n }\n\n /** Computes a 4x4 transformation matrix from a reference frame centered at\n * the provided origin to the ellipsoid's fixed reference frame.\n */\n localFrameToFixedFrame(\n firstAxis: string,\n secondAxis: string,\n thirdAxis: string,\n origin: Readonly<NumericArray>,\n result?: Matrix4\n ): Matrix4;\n localFrameToFixedFrame<Matrix4T>(\n firstAxis: string,\n secondAxis: string,\n thirdAxis: string,\n origin: Readonly<NumericArray>,\n result: number[]\n ): number[];\n\n // Computes a 4x4 transformation matrix from a reference frame centered at\n // the provided origin to the ellipsoid's fixed reference frame.\n localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);\n }\n\n /** Computes the unit vector directed from the center of this ellipsoid toward\n * the provided Cartesian position. */\n geocentricSurfaceNormal(cartesian: number[], result?: number[]): number[];\n geocentricSurfaceNormal<NumArray>(cartesian: number[], result: NumArray): NumArray;\n geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector.from(cartesian).normalize().to(result);\n }\n\n /** Computes the normal of the plane tangent to the surface of the ellipsoid at provided position. */\n geodeticSurfaceNormalCartographic<NumArray>(cartographic: number[], result: NumArray): NumArray;\n geodeticSurfaceNormalCartographic(cartographic: number[]): number[];\n geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {\n const cartographicVectorRadians = fromCartographicToRadians(cartographic);\n\n const longitude = cartographicVectorRadians[0];\n const latitude = cartographicVectorRadians[1];\n\n const cosLatitude = Math.cos(latitude);\n\n scratchVector\n .set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude))\n .normalize();\n\n return scratchVector.to(result);\n }\n\n /** Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position. */\n geodeticSurfaceNormal<NumArrayT>(cartesian: number[], result: NumArrayT): NumArrayT;\n geodeticSurfaceNormal(cartesian: number[]): number[];\n geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);\n }\n\n /** Scales the provided Cartesian position along the geodetic surface normal\n * so that it is on the surface of this ellipsoid. If the position is\n * at the center of the ellipsoid, this function returns undefined. */\n scaleToGeodeticSurface(cartesian: number[], result?: number[]): number[];\n scaleToGeodeticSurface(cartesian, result) {\n return scaleToGeodeticSurface(cartesian, this, result);\n }\n\n /** Scales the provided Cartesian position along the geocentric surface normal\n * so that it is on the surface of this ellipsoid. */\n scaleToGeocentricSurface(cartesian: number[], result?: number[]): number[];\n scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {\n scratchPosition.from(cartesian);\n\n const positionX = scratchPosition.x;\n const positionY = scratchPosition.y;\n const positionZ = scratchPosition.z;\n const oneOverRadiiSquared = this.oneOverRadiiSquared;\n\n const beta =\n 1.0 /\n Math.sqrt(\n positionX * positionX * oneOverRadiiSquared.x +\n positionY * positionY * oneOverRadiiSquared.y +\n positionZ * positionZ * oneOverRadiiSquared.z\n );\n\n return scratchPosition.multiplyScalar(beta).to(result);\n }\n\n /** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying\n * its components by the result of `Ellipsoid#oneOverRadii` */\n transformPositionToScaledSpace(position: number[], result?: number[]): number[];\n transformPositionToScaledSpace(position, result = [0, 0, 0]) {\n return scratchPosition.from(position).scale(this.oneOverRadii).to(result);\n }\n\n /** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying\n * its components by the result of `Ellipsoid#radii`. */\n transformPositionFromScaledSpace(position: number[], result?: number[]): number[];\n transformPositionFromScaledSpace(position, result = [0, 0, 0]) {\n return scratchPosition.from(position).scale(this.radii).to(result);\n }\n\n /** Computes a point which is the intersection of the surface normal with the z-axis. */\n getSurfaceNormalIntersectionWithZAxis(\n position: number[],\n buffer?: number,\n result?: number[]\n ): number[];\n getSurfaceNormalIntersectionWithZAxis(position, buffer = 0.0, result = [0, 0, 0]) {\n // Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)\n assert(equals(this.radii.x, this.radii.y, _MathUtils.EPSILON15));\n assert(this.radii.z > 0);\n\n scratchPosition.from(position);\n const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);\n\n if (Math.abs(z) >= this.radii.z - buffer) {\n return undefined;\n }\n\n return scratchPosition.set(0.0, 0.0, z).to(result);\n }\n}\n"],"file":"ellipsoid.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/ellipsoid/ellipsoid.ts"],"names":["scratchVector","Vector3","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","wgs84","Ellipsoid","x","y","z","_MathUtils","EPSILON1","radii","radiiSquared","radiiToTheFourth","oneOverRadii","oneOverRadiiSquared","minimumRadius","Math","min","maximumRadius","max","squaredXOverSquaredZ","Object","freeze","right","Boolean","equals","toString","cartographic","result","normal","k","height","geodeticSurfaceNormalCartographic","copy","scale","gamma","sqrt","dot","add","to","cartesian","from","point","scaleToGeodeticSurface","undefined","geodeticSurfaceNormal","h","subtract","longitude","atan2","latitude","asin","sign","vec3","length","origin","Matrix4","firstAxis","secondAxis","thirdAxis","normalize","cartographicVectorRadians","cosLatitude","cos","set","sin","positionX","positionY","positionZ","beta","multiplyScalar","position","buffer","EPSILON15","abs","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA;;AAUA;;AAEA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,aAAa,GAAG,IAAID,aAAJ,EAAtB;AACA,IAAME,QAAQ,GAAG,IAAIF,aAAJ,EAAjB;AACA,IAAMG,eAAe,GAAG,IAAIH,aAAJ,EAAxB;AACA,IAAMI,aAAa,GAAG,IAAIJ,aAAJ,EAAtB;AACA,IAAMK,gBAAgB,GAAG,IAAIL,aAAJ,EAAzB;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AAP,CAAqB;AAC3F,aAAO5B,eAAe,CAACyC,IAAhB,CAAqB8B,QAArB,EAA+BrC,KAA/B,CAAqC,KAAKxB,KAA1C,EAAiD6B,EAAjD,CAAoDX,MAApD,CAAP;AACD;;;WAGD,+CACE2C,QADF,EAIY;AAAA,UAFVC,MAEU,uEAFO,CAEP;AAAA,UADV5C,MACU,uEADS,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CACT;AAEV,wBAAO,kBAAO,KAAKlB,KAAL,CAAWL,CAAlB,EAAqB,KAAKK,KAAL,CAAWJ,CAAhC,EAAmCE,iBAAWiE,SAA9C,CAAP;AACA,wBAAO,KAAK/D,KAAL,CAAWH,CAAX,GAAe,CAAtB;AAEAP,MAAAA,eAAe,CAACyC,IAAhB,CAAqB8B,QAArB;AACA,UAAMhE,CAAC,GAAGP,eAAe,CAACO,CAAhB,IAAqB,IAAI,KAAKa,oBAA9B,CAAV;;AAEA,UAAIJ,IAAI,CAAC0D,GAAL,CAASnE,CAAT,KAAe,KAAKG,KAAL,CAAWH,CAAX,GAAeiE,MAAlC,EAA0C;AACxC,eAAO5B,SAAP;AACD;;AAED,aAAO5C,eAAe,CAACgE,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8BzD,CAA9B,EAAiCgC,EAAjC,CAAoCX,MAApC,CAAP;AACD;;;;;;8BAzOkBxB,S,WAEgB,IAAIA,SAAJ,CAAcuE,yBAAd,EAA8BC,yBAA9B,EAA8CC,yBAA9C,C","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {\n Vector3,\n Matrix4,\n toRadians,\n toDegrees,\n assert,\n equals,\n _MathUtils,\n NumericArray\n} from '@math.gl/core';\nimport * as vec3 from 'gl-matrix/vec3';\n\nimport {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';\nimport {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';\n\nimport scaleToGeodeticSurface from './helpers/scale-to-geodetic-surface';\nimport localFrameToFixedFrame from './helpers/ellipsoid-transform';\n\nconst scratchVector = new Vector3();\nconst scratchNormal = new Vector3();\nconst scratchK = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchHeight = new Vector3();\nconst scratchCartesian = new Vector3();\n\nlet wgs84;\n\n/**\n * A quadratic surface defined in Cartesian coordinates by the equation\n * `(x / a)^2 + (y / b)^2 + (z / c)^2 = 1`. Primarily used\n * to represent the shape of planetary bodies.\n */\nexport default class Ellipsoid {\n /** An Ellipsoid instance initialized to the WGS84 standard. */\n static readonly WGS84: Ellipsoid = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);\n\n readonly radii: Vector3;\n readonly radiiSquared: Vector3;\n readonly radiiToTheFourth: Vector3;\n readonly oneOverRadii: Vector3;\n readonly oneOverRadiiSquared: Vector3;\n readonly minimumRadius: number;\n readonly maximumRadius: number;\n readonly centerToleranceSquared: number = _MathUtils.EPSILON1;\n readonly squaredXOverSquaredZ: number;\n\n /** Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions. */\n constructor(x: number, y: number, z: number);\n constructor();\n\n constructor(x = 0.0, y = 0.0, z = 0.0) {\n assert(x >= 0.0);\n assert(y >= 0.0);\n assert(z >= 0.0);\n\n this.radii = new Vector3(x, y, z);\n\n this.radiiSquared = new Vector3(x * x, y * y, z * z);\n\n this.radiiToTheFourth = new Vector3(x * x * x * x, y * y * y * y, z * z * z * z);\n\n this.oneOverRadii = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / x,\n y === 0.0 ? 0.0 : 1.0 / y,\n z === 0.0 ? 0.0 : 1.0 / z\n );\n\n this.oneOverRadiiSquared = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / (x * x),\n y === 0.0 ? 0.0 : 1.0 / (y * y),\n z === 0.0 ? 0.0 : 1.0 / (z * z)\n );\n\n this.minimumRadius = Math.min(x, y, z);\n\n this.maximumRadius = Math.max(x, y, z);\n\n if (this.radiiSquared.z !== 0) {\n this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;\n }\n\n Object.freeze(this);\n }\n\n /** Compares this Ellipsoid against the provided Ellipsoid componentwise */\n equals(right: Ellipsoid): boolean {\n return this === right || Boolean(right && this.radii.equals(right.radii));\n }\n\n /** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */\n toString(): string {\n return this.radii.toString();\n }\n\n /** Converts the provided cartographic to Cartesian representation. */\n cartographicToCartesian(cartographic: number[], result: Vector3): Vector3;\n cartographicToCartesian(cartographic: number[], result?: number[]): number[];\n\n cartographicToCartesian(cartographic, result = [0, 0, 0]) {\n const normal = scratchNormal;\n const k = scratchK;\n\n const [, , height] = cartographic;\n this.geodeticSurfaceNormalCartographic(cartographic, normal);\n k.copy(this.radiiSquared).scale(normal);\n\n const gamma = Math.sqrt(normal.dot(k));\n k.scale(1 / gamma);\n\n normal.scale(height);\n\n k.add(normal);\n\n return k.to(result);\n }\n\n /** Converts the provided cartesian to cartographic (lng/lat/z) representation.\n * The cartesian is undefined at the center of the ellipsoid. */\n cartesianToCartographic(cartesian: number[], result: Vector3): Vector3;\n cartesianToCartographic(cartesian: number[], result?: number[]): number[];\n\n cartesianToCartographic(cartesian, result = [0, 0, 0]) {\n scratchCartesian.from(cartesian);\n const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);\n\n if (!point) {\n return undefined;\n }\n\n const normal = this.geodeticSurfaceNormal(point, scratchNormal);\n\n const h = scratchHeight;\n h.copy(scratchCartesian).subtract(point);\n\n const longitude = Math.atan2(normal.y, normal.x);\n const latitude = Math.asin(normal.z);\n const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);\n\n return toCartographicFromRadians([longitude, latitude, height], result);\n }\n\n /** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes\n * centered at the provided origin to the provided ellipsoid's fixed reference frame. */\n eastNorthUpToFixedFrame(origin: number[], result?: Matrix4): Matrix4;\n eastNorthUpToFixedFrame(origin: number[], result: number[]): number[];\n\n eastNorthUpToFixedFrame(origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, 'east', 'north', 'up', origin, result);\n }\n\n /** Computes a 4x4 transformation matrix from a reference frame centered at\n * the provided origin to the ellipsoid's fixed reference frame.\n */\n localFrameToFixedFrame(\n firstAxis: string,\n secondAxis: string,\n thirdAxis: string,\n origin: Readonly<NumericArray>,\n result?: Matrix4\n ): Matrix4;\n localFrameToFixedFrame<Matrix4T>(\n firstAxis: string,\n secondAxis: string,\n thirdAxis: string,\n origin: Readonly<NumericArray>,\n result: number[]\n ): number[];\n\n // Computes a 4x4 transformation matrix from a reference frame centered at\n // the provided origin to the ellipsoid's fixed reference frame.\n localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);\n }\n\n /** Computes the unit vector directed from the center of this ellipsoid toward\n * the provided Cartesian position. */\n geocentricSurfaceNormal(cartesian: number[], result?: number[]): number[];\n geocentricSurfaceNormal<NumArray>(cartesian: number[], result: NumArray): NumArray;\n geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector.from(cartesian).normalize().to(result);\n }\n\n /** Computes the normal of the plane tangent to the surface of the ellipsoid at provided position. */\n geodeticSurfaceNormalCartographic<NumArray>(cartographic: number[], result: NumArray): NumArray;\n geodeticSurfaceNormalCartographic(cartographic: number[]): number[];\n geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {\n const cartographicVectorRadians = fromCartographicToRadians(cartographic);\n\n const longitude = cartographicVectorRadians[0];\n const latitude = cartographicVectorRadians[1];\n\n const cosLatitude = Math.cos(latitude);\n\n scratchVector\n .set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude))\n .normalize();\n\n return scratchVector.to(result);\n }\n\n /** Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position. */\n geodeticSurfaceNormal<NumArrayT>(cartesian: number[], result: NumArrayT): NumArrayT;\n geodeticSurfaceNormal(cartesian: number[]): number[];\n geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);\n }\n\n /** Scales the provided Cartesian position along the geodetic surface normal\n * so that it is on the surface of this ellipsoid. If the position is\n * at the center of the ellipsoid, this function returns undefined. */\n scaleToGeodeticSurface(cartesian: number[], result?: number[]): number[] {\n return scaleToGeodeticSurface(cartesian, this, result);\n }\n\n /** Scales the provided Cartesian position along the geocentric surface normal\n * so that it is on the surface of this ellipsoid. */\n scaleToGeocentricSurface(cartesian: number[], result: number[] = [0, 0, 0]): number[] {\n scratchPosition.from(cartesian);\n\n const positionX = scratchPosition.x;\n const positionY = scratchPosition.y;\n const positionZ = scratchPosition.z;\n const oneOverRadiiSquared = this.oneOverRadiiSquared;\n\n const beta =\n 1.0 /\n Math.sqrt(\n positionX * positionX * oneOverRadiiSquared.x +\n positionY * positionY * oneOverRadiiSquared.y +\n positionZ * positionZ * oneOverRadiiSquared.z\n );\n\n return scratchPosition.multiplyScalar(beta).to(result);\n }\n\n /** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying\n * its components by the result of `Ellipsoid#oneOverRadii` */\n transformPositionToScaledSpace(position: number[], result: number[] = [0, 0, 0]): number[] {\n return scratchPosition.from(position).scale(this.oneOverRadii).to(result);\n }\n\n /** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying\n * its components by the result of `Ellipsoid#radii`. */\n transformPositionFromScaledSpace(position: number[], result: number[] = [0, 0, 0]): number[] {\n return scratchPosition.from(position).scale(this.radii).to(result);\n }\n\n /** Computes a point which is the intersection of the surface normal with the z-axis. */\n getSurfaceNormalIntersectionWithZAxis(\n position: number[],\n buffer: number = 0,\n result: number[] = [0, 0, 0]\n ): number[] {\n // Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)\n assert(equals(this.radii.x, this.radii.y, _MathUtils.EPSILON15));\n assert(this.radii.z > 0);\n\n scratchPosition.from(position);\n const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);\n\n if (Math.abs(z) >= this.radii.z - buffer) {\n return undefined;\n }\n\n return scratchPosition.set(0.0, 0.0, z).to(result);\n }\n}\n"],"file":"ellipsoid.js"}
|
|
@@ -7,9 +7,9 @@ exports.default = localFrameToFixedFrame;
|
|
|
7
7
|
|
|
8
8
|
var _core = require("@math.gl/core");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
var EPSILON14 = 1e-14;
|
|
11
|
+
var scratchOrigin = new _core.Vector3();
|
|
12
|
+
var VECTOR_PRODUCT_LOCAL_FRAME = {
|
|
13
13
|
up: {
|
|
14
14
|
south: 'east',
|
|
15
15
|
north: 'west',
|
|
@@ -47,7 +47,7 @@ const VECTOR_PRODUCT_LOCAL_FRAME = {
|
|
|
47
47
|
south: 'down'
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
var degeneratePositionLocalFrame = {
|
|
51
51
|
north: [-1, 0, 0],
|
|
52
52
|
east: [0, 1, 0],
|
|
53
53
|
up: [0, 0, 1],
|
|
@@ -55,7 +55,7 @@ const degeneratePositionLocalFrame = {
|
|
|
55
55
|
west: [0, -1, 0],
|
|
56
56
|
down: [0, 0, -1]
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
var scratchAxisVectors = {
|
|
59
59
|
east: new _core.Vector3(),
|
|
60
60
|
north: new _core.Vector3(),
|
|
61
61
|
up: new _core.Vector3(),
|
|
@@ -63,21 +63,21 @@ const scratchAxisVectors = {
|
|
|
63
63
|
south: new _core.Vector3(),
|
|
64
64
|
down: new _core.Vector3()
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
var scratchVector1 = new _core.Vector3();
|
|
67
|
+
var scratchVector2 = new _core.Vector3();
|
|
68
|
+
var scratchVector3 = new _core.Vector3();
|
|
69
69
|
|
|
70
70
|
function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, cartesianOrigin, result) {
|
|
71
|
-
|
|
71
|
+
var thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];
|
|
72
72
|
(0, _core.assert)(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
var firstAxisVector;
|
|
74
|
+
var secondAxisVector;
|
|
75
|
+
var thirdAxisVector;
|
|
76
|
+
var origin = scratchOrigin.copy(cartesianOrigin);
|
|
77
|
+
var atPole = (0, _core.equals)(origin.x, 0.0, EPSILON14) && (0, _core.equals)(origin.y, 0.0, EPSILON14);
|
|
78
78
|
|
|
79
79
|
if (atPole) {
|
|
80
|
-
|
|
80
|
+
var sign = Math.sign(origin.z);
|
|
81
81
|
firstAxisVector = scratchVector1.fromArray(degeneratePositionLocalFrame[firstAxis]);
|
|
82
82
|
|
|
83
83
|
if (firstAxis !== 'east' && firstAxis !== 'west') {
|
|
@@ -96,19 +96,15 @@ function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, car
|
|
|
96
96
|
thirdAxisVector.scale(sign);
|
|
97
97
|
}
|
|
98
98
|
} else {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
north
|
|
103
|
-
} = scratchAxisVectors;
|
|
99
|
+
var up = scratchAxisVectors.up,
|
|
100
|
+
east = scratchAxisVectors.east,
|
|
101
|
+
north = scratchAxisVectors.north;
|
|
104
102
|
east.set(-origin.y, origin.x, 0.0).normalize();
|
|
105
103
|
ellipsoid.geodeticSurfaceNormal(origin, up);
|
|
106
104
|
north.copy(up).cross(east);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
south
|
|
111
|
-
} = scratchAxisVectors;
|
|
105
|
+
var down = scratchAxisVectors.down,
|
|
106
|
+
west = scratchAxisVectors.west,
|
|
107
|
+
south = scratchAxisVectors.south;
|
|
112
108
|
down.copy(up).scale(-1);
|
|
113
109
|
west.copy(east).scale(-1);
|
|
114
110
|
south.copy(north).scale(-1);
|