@math.gl/geospatial 3.6.3 → 4.0.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/constants.js.map +1 -0
- package/dist/ellipsoid/ellipsoid.d.ts +9 -8
- package/dist/ellipsoid/ellipsoid.d.ts.map +1 -1
- package/dist/{esm/ellipsoid → ellipsoid}/ellipsoid.js +5 -6
- package/dist/ellipsoid/ellipsoid.js.map +1 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts +4 -4
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts.map +1 -1
- package/dist/{esm/ellipsoid → ellipsoid}/helpers/ellipsoid-transform.js +1 -1
- package/dist/ellipsoid/helpers/ellipsoid-transform.js.map +1 -0
- 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/{esm/ellipsoid → ellipsoid}/helpers/scale-to-geodetic-surface.js +1 -1
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.js.map +1 -0
- package/dist/index.cjs +407 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/type-utils.d.ts +6 -6
- package/dist/type-utils.d.ts.map +1 -1
- package/dist/{esm/type-utils.js → type-utils.js} +1 -1
- package/dist/type-utils.js.map +1 -0
- package/package.json +7 -6
- package/src/ellipsoid/ellipsoid.ts +33 -33
- package/src/ellipsoid/helpers/ellipsoid-transform.ts +14 -12
- package/src/ellipsoid/helpers/scale-to-geodetic-surface.ts +2 -2
- package/src/index.ts +1 -1
- package/src/type-utils.ts +15 -9
- package/dist/es5/constants.js +0 -22
- package/dist/es5/constants.js.map +0 -1
- package/dist/es5/ellipsoid/ellipsoid.js +0 -210
- package/dist/es5/ellipsoid/ellipsoid.js.map +0 -1
- package/dist/es5/ellipsoid/helpers/ellipsoid-transform.js +0 -134
- package/dist/es5/ellipsoid/helpers/ellipsoid-transform.js.map +0 -1
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js +0 -74
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js.map +0 -1
- package/dist/es5/index.js +0 -24
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/type-utils.js +0 -96
- package/dist/es5/type-utils.js.map +0 -1
- package/dist/esm/constants.js.map +0 -1
- package/dist/esm/ellipsoid/ellipsoid.js.map +0 -1
- package/dist/esm/ellipsoid/helpers/ellipsoid-transform.js.map +0 -1
- package/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js.map +0 -1
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/type-utils.js.map +0 -1
- /package/dist/{esm/constants.js → constants.js} +0 -0
|
@@ -0,0 +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":"AAGA,OAAO,MAAMA,cAAc,GAAG,SAAvB;AACP,OAAO,MAAMC,cAAc,GAAG,SAAvB;AACP,OAAO,MAAMC,cAAc,GAAG,kBAAvB;AAIP,OAAO,MAAMC,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"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Vector3, Matrix4, NumericArray } from '@math.gl/core';
|
|
2
|
+
import type { AxisDirection } from './helpers/ellipsoid-transform';
|
|
2
3
|
/**
|
|
3
4
|
* A quadratic surface defined in Cartesian coordinates by the equation
|
|
4
5
|
* `(x / a)^2 + (y / b)^2 + (z / c)^2 = 1`. Primarily used
|
|
5
6
|
* to represent the shape of planetary bodies.
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
+
export declare class Ellipsoid {
|
|
8
9
|
/** An Ellipsoid instance initialized to the WGS84 standard. */
|
|
9
10
|
static readonly WGS84: Ellipsoid;
|
|
10
11
|
readonly radii: Vector3;
|
|
@@ -28,23 +29,23 @@ export default class Ellipsoid {
|
|
|
28
29
|
cartographicToCartesian(cartographic: number[], result?: number[]): number[];
|
|
29
30
|
/** Converts the provided cartesian to cartographic (lng/lat/z) representation.
|
|
30
31
|
* The cartesian is undefined at the center of the ellipsoid. */
|
|
31
|
-
cartesianToCartographic(cartesian:
|
|
32
|
-
cartesianToCartographic(cartesian:
|
|
32
|
+
cartesianToCartographic(cartesian: Readonly<NumericArray>, result: Vector3): Vector3;
|
|
33
|
+
cartesianToCartographic(cartesian: Readonly<NumericArray>, result?: number[]): number[];
|
|
33
34
|
/** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes
|
|
34
35
|
* centered at the provided origin to the provided ellipsoid's fixed reference frame. */
|
|
35
|
-
eastNorthUpToFixedFrame(origin:
|
|
36
|
-
eastNorthUpToFixedFrame(origin:
|
|
36
|
+
eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, result?: Matrix4): Matrix4;
|
|
37
|
+
eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, result: number[]): number[];
|
|
37
38
|
/** Computes a 4x4 transformation matrix from a reference frame centered at
|
|
38
39
|
* the provided origin to the ellipsoid's fixed reference frame.
|
|
39
40
|
*/
|
|
40
|
-
localFrameToFixedFrame(firstAxis:
|
|
41
|
-
localFrameToFixedFrame<Matrix4T>(firstAxis:
|
|
41
|
+
localFrameToFixedFrame(firstAxis: AxisDirection, secondAxis: AxisDirection, thirdAxis: AxisDirection, origin: Readonly<NumericArray>, result?: Matrix4): Matrix4;
|
|
42
|
+
localFrameToFixedFrame<Matrix4T>(firstAxis: AxisDirection, secondAxis: AxisDirection, thirdAxis: AxisDirection, origin: Readonly<NumericArray>, result: number[]): number[];
|
|
42
43
|
/** Computes the unit vector directed from the center of this ellipsoid toward
|
|
43
44
|
* the provided Cartesian position. */
|
|
44
45
|
geocentricSurfaceNormal(cartesian: number[], result?: number[]): number[];
|
|
45
46
|
geocentricSurfaceNormal<NumArray>(cartesian: number[], result: NumArray): NumArray;
|
|
46
47
|
/** Computes the normal of the plane tangent to the surface of the ellipsoid at provided position. */
|
|
47
|
-
geodeticSurfaceNormalCartographic<NumArray>(cartographic:
|
|
48
|
+
geodeticSurfaceNormalCartographic<NumArray>(cartographic: Readonly<NumericArray>, result: NumArray): NumArray;
|
|
48
49
|
geodeticSurfaceNormalCartographic(cartographic: number[]): number[];
|
|
49
50
|
/** Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position. */
|
|
50
51
|
geodeticSurfaceNormal<NumArrayT>(cartesian: number[], result: NumArrayT): NumArrayT;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ellipsoid.d.ts","sourceRoot":"","sources":["../../src/ellipsoid/ellipsoid.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"ellipsoid.d.ts","sourceRoot":"","sources":["../../src/ellipsoid/ellipsoid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAA8B,YAAY,EAAC,MAAM,eAAe,CAAC;AAOzF,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAWjE;;;;GAIG;AACH,qBAAa,SAAS;IACpB,+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,QAA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AqC,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAM,EAAc,GAC3B,MAAM,EAAE;CAcZ"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { Vector3, Matrix4, assert, equals, _MathUtils } from '@math.gl/core';
|
|
3
3
|
import * as vec3 from 'gl-matrix/vec3';
|
|
4
|
-
import { WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z } from
|
|
5
|
-
import { fromCartographicToRadians, toCartographicFromRadians } from
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import { WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z } from "../constants.js";
|
|
5
|
+
import { fromCartographicToRadians, toCartographicFromRadians } from "../type-utils.js";
|
|
6
|
+
import { localFrameToFixedFrame } from "./helpers/ellipsoid-transform.js";
|
|
7
|
+
import { scaleToGeodeticSurface } from "./helpers/scale-to-geodetic-surface.js";
|
|
8
8
|
const scratchVector = new Vector3();
|
|
9
9
|
const scratchNormal = new Vector3();
|
|
10
10
|
const scratchK = new Vector3();
|
|
11
11
|
const scratchPosition = new Vector3();
|
|
12
12
|
const scratchHeight = new Vector3();
|
|
13
13
|
const scratchCartesian = new Vector3();
|
|
14
|
-
|
|
15
|
-
export default class Ellipsoid {
|
|
14
|
+
export class Ellipsoid {
|
|
16
15
|
constructor(x = 0.0, y = 0.0, z = 0.0) {
|
|
17
16
|
_defineProperty(this, "radii", void 0);
|
|
18
17
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ellipsoid/ellipsoid.ts"],"names":["Vector3","Matrix4","assert","equals","_MathUtils","vec3","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","fromCartographicToRadians","toCartographicFromRadians","localFrameToFixedFrame","scaleToGeodeticSurface","scratchVector","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","Ellipsoid","constructor","x","y","z","EPSILON1","radii","radiiSquared","radiiToTheFourth","oneOverRadii","oneOverRadiiSquared","minimumRadius","Math","min","maximumRadius","max","squaredXOverSquaredZ","Object","freeze","right","Boolean","toString","cartographicToCartesian","cartographic","result","normal","k","height","geodeticSurfaceNormalCartographic","copy","scale","gamma","sqrt","dot","add","to","cartesianToCartographic","cartesian","from","point","undefined","geodeticSurfaceNormal","h","subtract","longitude","atan2","latitude","asin","sign","length","eastNorthUpToFixedFrame","origin","firstAxis","secondAxis","thirdAxis","geocentricSurfaceNormal","normalize","cartographicVectorRadians","cosLatitude","cos","set","sin","scaleToGeocentricSurface","positionX","positionY","positionZ","beta","multiplyScalar","transformPositionToScaledSpace","position","transformPositionFromScaledSpace","getSurfaceNormalIntersectionWithZAxis","buffer","EPSILON15","abs"],"mappings":";AAIA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,MAAlC,EAA0CC,UAA1C,QAAyE,eAAzE;AAEA,OAAO,KAAKC,IAAZ,MAAsB,gBAAtB;SAEQC,c,EAAgBC,c,EAAgBC,c;SAChCC,yB,EAA2BC,yB;SAG3BC,sB;SACAC,sB;AAER,MAAMC,aAAa,GAAG,IAAIb,OAAJ,EAAtB;AACA,MAAMc,aAAa,GAAG,IAAId,OAAJ,EAAtB;AACA,MAAMe,QAAQ,GAAG,IAAIf,OAAJ,EAAjB;AACA,MAAMgB,eAAe,GAAG,IAAIhB,OAAJ,EAAxB;AACA,MAAMiB,aAAa,GAAG,IAAIjB,OAAJ,EAAtB;AACA,MAAMkB,gBAAgB,GAAG,IAAIlB,OAAJ,EAAzB;AAOA,OAAO,MAAMmB,SAAN,CAAgB;AAkBrBC,EAAAA,WAAW,CAACC,CAAC,GAAG,GAAL,EAAUC,CAAC,GAAG,GAAd,EAAmBC,CAAC,GAAG,GAAvB,EAA4B;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA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EAA6D;AAC3F,WAAO3B,eAAe,CAACyC,IAAhB,CAAqB+B,QAArB,EAA+BvC,KAA/B,CAAqC,KAAKxB,KAA1C,EAAiD6B,EAAjD,CAAoDX,MAApD,CAAP;AACD;;AAGD+C,EAAAA,qCAAqC,CACnCF,QADmC,EAEnCG,MAAc,GAAG,CAFkB,EAGnChD,MAAgB,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAHgB,EAIzB;AAEVzC,IAAAA,MAAM,CAACC,MAAM,CAAC,KAAKsB,KAAL,CAAWJ,CAAZ,EAAe,KAAKI,KAAL,CAAWH,CAA1B,EAA6BlB,UAAU,CAACwF,SAAxC,CAAP,CAAN;AACA1F,IAAAA,MAAM,CAAC,KAAKuB,KAAL,CAAWF,CAAX,GAAe,CAAhB,CAAN;AAEAP,IAAAA,eAAe,CAACyC,IAAhB,CAAqB+B,QAArB;AACA,UAAMjE,CAAC,GAAGP,eAAe,CAACO,CAAhB,IAAqB,IAAI,KAAKY,oBAA9B,CAAV;;AAEA,QAAIJ,IAAI,CAAC8D,GAAL,CAAStE,CAAT,KAAe,KAAKE,KAAL,CAAWF,CAAX,GAAeoE,MAAlC,EAA0C;AACxC,aAAOhC,SAAP;AACD;;AAED,WAAO3C,eAAe,CAAC+D,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8BxD,CAA9B,EAAiC+B,EAAjC,CAAoCX,MAApC,CAAP;AACD;;AAlPoB;;gBAAVxB,S,WAEwB,IAAIA,SAAJ,CAAcb,cAAd,EAA8BC,cAA9B,EAA8CC,cAA9C,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 {Vector3, Matrix4, assert, equals, _MathUtils, NumericArray} from '@math.gl/core';\n// @ts-ignore gl-matrix typings...\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 type {AxisDirection} from './helpers/ellipsoid-transform';\nimport {localFrameToFixedFrame} from './helpers/ellipsoid-transform';\nimport {scaleToGeodeticSurface} from './helpers/scale-to-geodetic-surface';\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\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 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: Readonly<NumericArray>, 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: Readonly<NumericArray>, result: Vector3): Vector3;\n cartesianToCartographic(cartesian: Readonly<NumericArray>, result?: number[]): number[];\n\n cartesianToCartographic(cartesian: Readonly<NumericArray>, 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: Readonly<NumericArray>, result?: Matrix4): Matrix4;\n eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, result: number[]): number[];\n\n eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, 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: AxisDirection,\n secondAxis: AxisDirection,\n thirdAxis: AxisDirection,\n origin: Readonly<NumericArray>,\n result?: Matrix4\n ): Matrix4;\n localFrameToFixedFrame<Matrix4T>(\n firstAxis: AxisDirection,\n secondAxis: AxisDirection,\n thirdAxis: AxisDirection,\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(\n firstAxis: AxisDirection,\n secondAxis: AxisDirection,\n thirdAxis: AxisDirection,\n origin: Readonly<NumericArray>,\n result = new Matrix4()\n ) {\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: Readonly<NumericArray>, 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>(\n cartographic: Readonly<NumericArray>,\n result: NumArray\n ): NumArray;\n geodeticSurfaceNormalCartographic(cartographic: number[]): number[];\n geodeticSurfaceNormalCartographic(cartographic: Readonly<NumericArray>, 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: Readonly<NumericArray>, 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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
import { NumericArray } from '@math.gl/core';
|
|
2
|
+
import type { Ellipsoid } from '../ellipsoid';
|
|
3
|
+
export declare type AxisDirection = 'up' | 'down' | 'north' | 'east' | 'south' | 'west';
|
|
4
|
+
export declare function localFrameToFixedFrame(ellipsoid: Ellipsoid, firstAxis: AxisDirection, secondAxis: AxisDirection, thirdAxis: AxisDirection, cartesianOrigin: Readonly<NumericArray>, result: number[]): number[];
|
|
5
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":"AAAA,OAAO,EAAC,YAAY,EAA2C,MAAM,eAAe,CAAC;AAErF,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAM5C,oBAAY,aAAa,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAsEhF,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,SAAS,EAAE,aAAa,EACxB,eAAe,EAAE,QAAQ,CAAC,YAAY,CAAC,EACvC,MAAM,EAAE,MAAM,EAAE,GACf,MAAM,EAAE,CAuEV"}
|
|
@@ -58,7 +58,7 @@ const scratchAxisVectors = {
|
|
|
58
58
|
const scratchVector1 = new Vector3();
|
|
59
59
|
const scratchVector2 = new Vector3();
|
|
60
60
|
const scratchVector3 = new Vector3();
|
|
61
|
-
export
|
|
61
|
+
export function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, cartesianOrigin, result) {
|
|
62
62
|
const thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];
|
|
63
63
|
assert(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));
|
|
64
64
|
let firstAxisVector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ellipsoid/helpers/ellipsoid-transform.ts"],"names":["Vector3","assert","equals","equalsEpsilon","EPSILON14","scratchOrigin","VECTOR_PRODUCT_LOCAL_FRAME","up","south","north","west","east","down","degeneratePositionLocalFrame","scratchAxisVectors","scratchVector1","scratchVector2","scratchVector3","localFrameToFixedFrame","ellipsoid","firstAxis","secondAxis","thirdAxis","cartesianOrigin","result","thirdAxisInferred","firstAxisVector","secondAxisVector","thirdAxisVector","origin","copy","atPole","x","y","sign","Math","z","fromArray","scale","set","normalize","geodeticSurfaceNormal","cross"],"mappings":"AAAA,SAAsBA,OAAtB,EAA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M,CAAC,CAAD,CAAN,GAAYI,eAAe,CAACK,CAA5B;AACAT,EAAAA,MAAM,CAAC,EAAD,CAAN,GAAaI,eAAe,CAACQ,CAA7B;AACAZ,EAAAA,MAAM,CAAC,EAAD,CAAN,GAAa,GAAb;AACAA,EAAAA,MAAM,CAAC,EAAD,CAAN,GAAaK,MAAM,CAACG,CAApB;AACAR,EAAAA,MAAM,CAAC,EAAD,CAAN,GAAaK,MAAM,CAACI,CAApB;AACAT,EAAAA,MAAM,CAAC,EAAD,CAAN,GAAaK,MAAM,CAACO,CAApB;AACAZ,EAAAA,MAAM,CAAC,EAAD,CAAN,GAAa,GAAb;AACA,SAAOA,MAAP;AACD","sourcesContent":["import {NumericArray, Vector3, assert, equals as equalsEpsilon} from '@math.gl/core';\n\nimport type {Ellipsoid} from '../ellipsoid';\n\nconst EPSILON14 = 1e-14;\n\nconst scratchOrigin = new Vector3();\n\nexport type AxisDirection = 'up' | 'down' | 'north' | 'east' | 'south' | 'west';\n\n// Caclulate third axis from given two axii\nconst VECTOR_PRODUCT_LOCAL_FRAME: Record<\n AxisDirection,\n Partial<Record<AxisDirection, AxisDirection>>\n> = {\n up: {\n south: 'east',\n north: 'west',\n west: 'south',\n east: 'north'\n },\n down: {\n south: 'west',\n north: 'east',\n west: 'north',\n east: 'south'\n },\n south: {\n up: 'west',\n down: 'east',\n west: 'down',\n east: 'up'\n },\n north: {\n up: 'east',\n down: 'west',\n west: 'up',\n east: 'down'\n },\n west: {\n up: 'north',\n down: 'south',\n north: 'down',\n south: 'up'\n },\n east: {\n up: 'south',\n down: 'north',\n north: 'up',\n south: 'down'\n }\n} as const;\n\nconst degeneratePositionLocalFrame = {\n north: [-1, 0, 0],\n east: [0, 1, 0],\n up: [0, 0, 1],\n south: [1, 0, 0],\n west: [0, -1, 0],\n down: [0, 0, -1]\n} as const;\n\nconst scratchAxisVectors = {\n east: new Vector3(),\n north: new Vector3(),\n up: new Vector3(),\n west: new Vector3(),\n south: new Vector3(),\n down: new Vector3()\n};\n\nconst scratchVector1 = new Vector3();\nconst scratchVector2 = new Vector3();\nconst scratchVector3 = new Vector3();\n\n// Computes a 4x4 transformation matrix from a reference frame\n// centered at the provided origin to the provided ellipsoid's fixed reference frame.\n// eslint-disable-next-line max-statements, max-params, complexity\nexport function localFrameToFixedFrame(\n ellipsoid: Ellipsoid,\n firstAxis: AxisDirection,\n secondAxis: AxisDirection,\n thirdAxis: AxisDirection,\n cartesianOrigin: Readonly<NumericArray>,\n result: number[]\n): number[] {\n const thirdAxisInferred =\n VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];\n // firstAxis and secondAxis must be east, north, up, west, south or down.');\n assert(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));\n\n let firstAxisVector: Vector3;\n let secondAxisVector: Vector3;\n let thirdAxisVector: Vector3;\n\n const origin = scratchOrigin.copy(cartesianOrigin);\n\n // If x and y are zero, assume origin is at a pole, which is a special case.\n const atPole = equalsEpsilon(origin.x, 0.0, EPSILON14) && equalsEpsilon(origin.y, 0.0, EPSILON14);\n\n if (atPole) {\n // Look up axis value and adjust\n const sign = Math.sign(origin.z);\n\n firstAxisVector = scratchVector1.fromArray(degeneratePositionLocalFrame[firstAxis]);\n if (firstAxis !== 'east' && firstAxis !== 'west') {\n firstAxisVector.scale(sign);\n }\n\n secondAxisVector = scratchVector2.fromArray(degeneratePositionLocalFrame[secondAxis]);\n if (secondAxis !== 'east' && secondAxis !== 'west') {\n secondAxisVector.scale(sign);\n }\n\n thirdAxisVector = scratchVector3.fromArray(degeneratePositionLocalFrame[thirdAxis]);\n if (thirdAxis !== 'east' && thirdAxis !== 'west') {\n thirdAxisVector.scale(sign);\n }\n } else {\n // Calculate all axis\n const {up, east, north} = scratchAxisVectors;\n\n east.set(-origin.y, origin.x, 0.0).normalize();\n ellipsoid.geodeticSurfaceNormal(origin, up);\n north.copy(up).cross(east);\n\n const {down, west, south} = scratchAxisVectors;\n\n down.copy(up).scale(-1);\n west.copy(east).scale(-1);\n south.copy(north).scale(-1);\n\n // Pick three axis based on desired orientation\n firstAxisVector = scratchAxisVectors[firstAxis];\n secondAxisVector = scratchAxisVectors[secondAxis];\n thirdAxisVector = scratchAxisVectors[thirdAxis];\n }\n\n // TODO - assuming the result is column-major\n result[0] = firstAxisVector.x;\n result[1] = firstAxisVector.y;\n result[2] = firstAxisVector.z;\n result[3] = 0.0;\n result[4] = secondAxisVector.x;\n result[5] = secondAxisVector.y;\n result[6] = secondAxisVector.z;\n result[7] = 0.0;\n result[8] = thirdAxisVector.x;\n result[9] = thirdAxisVector.y;\n result[10] = thirdAxisVector.z;\n result[11] = 0.0;\n result[12] = origin.x;\n result[13] = origin.y;\n result[14] = origin.z;\n result[15] = 1.0;\n return result;\n}\n"],"file":"ellipsoid-transform.js"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type Ellipsoid from '../ellipsoid';
|
|
2
|
-
export
|
|
1
|
+
import type { Ellipsoid } from '../ellipsoid';
|
|
2
|
+
export declare 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":"AAEA,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;
|
|
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,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAS5C,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EAAE,EACnB,SAAS,EAAE,SAAS,EACpB,MAAM,GAAE,MAAM,EAAO,GACpB,MAAM,EAAE,CAuFV"}
|
|
@@ -2,7 +2,7 @@ import { Vector3, _MathUtils } from '@math.gl/core';
|
|
|
2
2
|
const scratchVector = new Vector3();
|
|
3
3
|
const scaleToGeodeticSurfaceIntersection = new Vector3();
|
|
4
4
|
const scaleToGeodeticSurfaceGradient = new Vector3();
|
|
5
|
-
export
|
|
5
|
+
export function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
|
|
6
6
|
const {
|
|
7
7
|
oneOverRadii,
|
|
8
8
|
oneOverRadiiSquared,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ellipsoid/helpers/scale-to-geodetic-surface.ts"],"names":["Vector3","_MathUtils","scratchVector","scaleToGeodeticSurfaceIntersection","scaleToGeodeticSurfaceGradient","scaleToGeodeticSurface","cartesian","ellipsoid","result","oneOverRadii","oneOverRadiiSquared","centerToleranceSquared","from","positionX","x","positionY","y","positionZ","z","oneOverRadiiX","oneOverRadiiY","oneOverRadiiZ","x2","y2","z2","squaredNorm","ratio","Math","sqrt","Number","isFinite","undefined","intersection","copy","scale","to","oneOverRadiiSquaredX","oneOverRadiiSquaredY","oneOverRadiiSquaredZ","gradient","set","lambda","len","correction","xMultiplier","yMultiplier","zMultiplier","func","xMultiplier2","yMultiplier2","zMultiplier2","xMultiplier3","yMultiplier3","zMultiplier3","denominator","derivative","abs","EPSILON12"],"mappings":"AACA,SAAQA,OAAR,EAAiBC,UAAjB,QAAkC,eAAlC;AAGA,MAAMC,aAAa,GAAG,IAAIF,OAAJ,EAAtB;AACA,MAAMG,kCAAkC,GAAG,IAAIH,OAAJ,EAA3C;AACA,MAAMI,8BAA8B,GAAG,IAAIJ,OAAJ,EAAvC;AAKA,OAAO,SAASK,sBAAT,CACLC,SADK,EAELC,SAFK,EAGLC,MAAgB,GAAG,EAHd,EAIK;AACV,QAAM;AAACC,IAAAA,YAAD;AAAeC,IAAAA,mBAAf;AAAoCC,IAAAA;AAApC,MAA8DJ,SAApE;AA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CAAC,GAAD,GAAOD,WAA1B;AAEAX,IAAAA,UAAU,GAAGI,IAAI,GAAGQ,UAApB;AACD,GA3BD,QA2BS5B,IAAI,CAAC6B,GAAL,CAAST,IAAT,IAAiB9C,UAAU,CAACwD,SA3BrC;;AA6BA,SAAOvD,aAAa,CAACgC,KAAd,CAAoB,CAACU,WAAD,EAAcC,WAAd,EAA2BC,WAA3B,CAApB,EAA6DX,EAA7D,CAAgE3B,MAAhE,CAAP;AACD","sourcesContent":["/* eslint-disable */\nimport {Vector3, _MathUtils} from '@math.gl/core';\nimport type {Ellipsoid} from '../ellipsoid';\n\nconst scratchVector = new Vector3();\nconst scaleToGeodeticSurfaceIntersection = new Vector3();\nconst scaleToGeodeticSurfaceGradient = new Vector3();\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.\nexport function scaleToGeodeticSurface(\n cartesian: number[],\n ellipsoid: Ellipsoid,\n result: number[] = []\n): number[] {\n const {oneOverRadii, oneOverRadiiSquared, centerToleranceSquared} = ellipsoid;\n\n scratchVector.from(cartesian);\n\n const positionX = scratchVector.x;\n const positionY = scratchVector.y;\n const positionZ = scratchVector.z;\n\n const oneOverRadiiX = oneOverRadii.x;\n const oneOverRadiiY = oneOverRadii.y;\n const oneOverRadiiZ = oneOverRadii.z;\n\n const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;\n const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;\n const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;\n\n // Compute the squared ellipsoid norm.\n const squaredNorm = x2 + y2 + z2;\n const ratio = Math.sqrt(1.0 / squaredNorm);\n\n // When very close to center or at center\n if (!Number.isFinite(ratio)) {\n return undefined;\n }\n\n // As an initial approximation, assume that the radial intersection is the projection point.\n const intersection = scaleToGeodeticSurfaceIntersection;\n intersection.copy(cartesian).scale(ratio);\n\n // If the position is near the center, the iteration will not converge.\n if (squaredNorm < centerToleranceSquared) {\n return intersection.to(result);\n }\n\n const oneOverRadiiSquaredX = oneOverRadiiSquared.x;\n const oneOverRadiiSquaredY = oneOverRadiiSquared.y;\n const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;\n\n // Use the gradient at the intersection point in place of the true unit normal.\n // The difference in magnitude will be absorbed in the multiplier.\n const gradient = scaleToGeodeticSurfaceGradient;\n gradient.set(\n intersection.x * oneOverRadiiSquaredX * 2.0,\n intersection.y * oneOverRadiiSquaredY * 2.0,\n intersection.z * oneOverRadiiSquaredZ * 2.0\n );\n\n // Compute the initial guess at the normal vector multiplier, lambda.\n let lambda = ((1.0 - ratio) * scratchVector.len()) / (0.5 * gradient.len());\n let correction = 0.0;\n\n let xMultiplier;\n let yMultiplier;\n let zMultiplier;\n let func;\n\n do {\n lambda -= correction;\n\n xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX);\n yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY);\n zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ);\n\n const xMultiplier2 = xMultiplier * xMultiplier;\n const yMultiplier2 = yMultiplier * yMultiplier;\n const zMultiplier2 = zMultiplier * zMultiplier;\n\n const xMultiplier3 = xMultiplier2 * xMultiplier;\n const yMultiplier3 = yMultiplier2 * yMultiplier;\n const zMultiplier3 = zMultiplier2 * zMultiplier;\n\n func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0;\n\n // \"denominator\" here refers to the use of this expression in the velocity and acceleration\n // computations in the sections to follow.\n const denominator =\n x2 * xMultiplier3 * oneOverRadiiSquaredX +\n y2 * yMultiplier3 * oneOverRadiiSquaredY +\n z2 * zMultiplier3 * oneOverRadiiSquaredZ;\n\n const derivative = -2.0 * denominator;\n\n correction = func / derivative;\n } while (Math.abs(func) > _MathUtils.EPSILON12);\n\n return scratchVector.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);\n}\n"],"file":"scale-to-geodetic-surface.js"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/index.ts
|
|
26
|
+
var src_exports = {};
|
|
27
|
+
__export(src_exports, {
|
|
28
|
+
Ellipsoid: () => Ellipsoid,
|
|
29
|
+
isWGS84: () => isWGS84
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
|
|
33
|
+
// src/ellipsoid/ellipsoid.ts
|
|
34
|
+
var import_core4 = require("@math.gl/core");
|
|
35
|
+
var vec3 = __toESM(require("gl-matrix/vec3"), 1);
|
|
36
|
+
|
|
37
|
+
// src/constants.ts
|
|
38
|
+
var WGS84_RADIUS_X = 6378137;
|
|
39
|
+
var WGS84_RADIUS_Y = 6378137;
|
|
40
|
+
var WGS84_RADIUS_Z = 6356752314245179e-9;
|
|
41
|
+
var WGS84_CONSTANTS = {
|
|
42
|
+
radii: [WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z],
|
|
43
|
+
radiiSquared: [
|
|
44
|
+
WGS84_RADIUS_X * WGS84_RADIUS_X,
|
|
45
|
+
WGS84_RADIUS_Y * WGS84_RADIUS_Y,
|
|
46
|
+
WGS84_RADIUS_Z * WGS84_RADIUS_Z
|
|
47
|
+
],
|
|
48
|
+
oneOverRadii: [1 / WGS84_RADIUS_X, 1 / WGS84_RADIUS_Y, 1 / WGS84_RADIUS_Z],
|
|
49
|
+
oneOverRadiiSquared: [
|
|
50
|
+
1 / (WGS84_RADIUS_X * WGS84_RADIUS_X),
|
|
51
|
+
1 / (WGS84_RADIUS_Y * WGS84_RADIUS_Y),
|
|
52
|
+
1 / (WGS84_RADIUS_Z * WGS84_RADIUS_Z)
|
|
53
|
+
],
|
|
54
|
+
maximumRadius: Math.max(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z),
|
|
55
|
+
centerToleranceSquared: 0.1
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// src/type-utils.ts
|
|
59
|
+
var import_core = require("@math.gl/core");
|
|
60
|
+
function identity(x) {
|
|
61
|
+
return x;
|
|
62
|
+
}
|
|
63
|
+
var scratchVector = new import_core.Vector3();
|
|
64
|
+
function fromCartographic(cartographic, result = [], map = identity) {
|
|
65
|
+
if ("longitude" in cartographic) {
|
|
66
|
+
result[0] = map(cartographic.longitude);
|
|
67
|
+
result[1] = map(cartographic.latitude);
|
|
68
|
+
result[2] = cartographic.height;
|
|
69
|
+
} else if ("x" in cartographic) {
|
|
70
|
+
result[0] = map(cartographic.x);
|
|
71
|
+
result[1] = map(cartographic.y);
|
|
72
|
+
result[2] = cartographic.z;
|
|
73
|
+
} else {
|
|
74
|
+
result[0] = map(cartographic[0]);
|
|
75
|
+
result[1] = map(cartographic[1]);
|
|
76
|
+
result[2] = cartographic[2];
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function fromCartographicToRadians(cartographic, vector = []) {
|
|
81
|
+
return fromCartographic(cartographic, vector, import_core.config._cartographicRadians ? identity : import_core.toRadians);
|
|
82
|
+
}
|
|
83
|
+
function toCartographic(vector, cartographic, map = identity) {
|
|
84
|
+
if ("longitude" in cartographic) {
|
|
85
|
+
cartographic.longitude = map(vector[0]);
|
|
86
|
+
cartographic.latitude = map(vector[1]);
|
|
87
|
+
cartographic.height = vector[2];
|
|
88
|
+
} else if ("x" in cartographic) {
|
|
89
|
+
cartographic.x = map(vector[0]);
|
|
90
|
+
cartographic.y = map(vector[1]);
|
|
91
|
+
cartographic.z = vector[2];
|
|
92
|
+
} else {
|
|
93
|
+
cartographic[0] = map(vector[0]);
|
|
94
|
+
cartographic[1] = map(vector[1]);
|
|
95
|
+
cartographic[2] = vector[2];
|
|
96
|
+
}
|
|
97
|
+
return cartographic;
|
|
98
|
+
}
|
|
99
|
+
function toCartographicFromRadians(vector, cartographic) {
|
|
100
|
+
return toCartographic(vector, cartographic, import_core.config._cartographicRadians ? identity : import_core.toDegrees);
|
|
101
|
+
}
|
|
102
|
+
function isWGS84(vector) {
|
|
103
|
+
if (!vector) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
scratchVector.from(vector);
|
|
107
|
+
const { oneOverRadiiSquared, centerToleranceSquared } = WGS84_CONSTANTS;
|
|
108
|
+
const x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];
|
|
109
|
+
const y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];
|
|
110
|
+
const z2 = vector[2] * vector[2] * oneOverRadiiSquared[2];
|
|
111
|
+
return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/ellipsoid/helpers/ellipsoid-transform.ts
|
|
115
|
+
var import_core2 = require("@math.gl/core");
|
|
116
|
+
var EPSILON14 = 1e-14;
|
|
117
|
+
var scratchOrigin = new import_core2.Vector3();
|
|
118
|
+
var VECTOR_PRODUCT_LOCAL_FRAME = {
|
|
119
|
+
up: {
|
|
120
|
+
south: "east",
|
|
121
|
+
north: "west",
|
|
122
|
+
west: "south",
|
|
123
|
+
east: "north"
|
|
124
|
+
},
|
|
125
|
+
down: {
|
|
126
|
+
south: "west",
|
|
127
|
+
north: "east",
|
|
128
|
+
west: "north",
|
|
129
|
+
east: "south"
|
|
130
|
+
},
|
|
131
|
+
south: {
|
|
132
|
+
up: "west",
|
|
133
|
+
down: "east",
|
|
134
|
+
west: "down",
|
|
135
|
+
east: "up"
|
|
136
|
+
},
|
|
137
|
+
north: {
|
|
138
|
+
up: "east",
|
|
139
|
+
down: "west",
|
|
140
|
+
west: "up",
|
|
141
|
+
east: "down"
|
|
142
|
+
},
|
|
143
|
+
west: {
|
|
144
|
+
up: "north",
|
|
145
|
+
down: "south",
|
|
146
|
+
north: "down",
|
|
147
|
+
south: "up"
|
|
148
|
+
},
|
|
149
|
+
east: {
|
|
150
|
+
up: "south",
|
|
151
|
+
down: "north",
|
|
152
|
+
north: "up",
|
|
153
|
+
south: "down"
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var degeneratePositionLocalFrame = {
|
|
157
|
+
north: [-1, 0, 0],
|
|
158
|
+
east: [0, 1, 0],
|
|
159
|
+
up: [0, 0, 1],
|
|
160
|
+
south: [1, 0, 0],
|
|
161
|
+
west: [0, -1, 0],
|
|
162
|
+
down: [0, 0, -1]
|
|
163
|
+
};
|
|
164
|
+
var scratchAxisVectors = {
|
|
165
|
+
east: new import_core2.Vector3(),
|
|
166
|
+
north: new import_core2.Vector3(),
|
|
167
|
+
up: new import_core2.Vector3(),
|
|
168
|
+
west: new import_core2.Vector3(),
|
|
169
|
+
south: new import_core2.Vector3(),
|
|
170
|
+
down: new import_core2.Vector3()
|
|
171
|
+
};
|
|
172
|
+
var scratchVector1 = new import_core2.Vector3();
|
|
173
|
+
var scratchVector2 = new import_core2.Vector3();
|
|
174
|
+
var scratchVector3 = new import_core2.Vector3();
|
|
175
|
+
function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, cartesianOrigin, result) {
|
|
176
|
+
const thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];
|
|
177
|
+
(0, import_core2.assert)(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));
|
|
178
|
+
let firstAxisVector;
|
|
179
|
+
let secondAxisVector;
|
|
180
|
+
let thirdAxisVector;
|
|
181
|
+
const origin = scratchOrigin.copy(cartesianOrigin);
|
|
182
|
+
const atPole = (0, import_core2.equals)(origin.x, 0, EPSILON14) && (0, import_core2.equals)(origin.y, 0, EPSILON14);
|
|
183
|
+
if (atPole) {
|
|
184
|
+
const sign = Math.sign(origin.z);
|
|
185
|
+
firstAxisVector = scratchVector1.fromArray(degeneratePositionLocalFrame[firstAxis]);
|
|
186
|
+
if (firstAxis !== "east" && firstAxis !== "west") {
|
|
187
|
+
firstAxisVector.scale(sign);
|
|
188
|
+
}
|
|
189
|
+
secondAxisVector = scratchVector2.fromArray(degeneratePositionLocalFrame[secondAxis]);
|
|
190
|
+
if (secondAxis !== "east" && secondAxis !== "west") {
|
|
191
|
+
secondAxisVector.scale(sign);
|
|
192
|
+
}
|
|
193
|
+
thirdAxisVector = scratchVector3.fromArray(degeneratePositionLocalFrame[thirdAxis]);
|
|
194
|
+
if (thirdAxis !== "east" && thirdAxis !== "west") {
|
|
195
|
+
thirdAxisVector.scale(sign);
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
const { up, east, north } = scratchAxisVectors;
|
|
199
|
+
east.set(-origin.y, origin.x, 0).normalize();
|
|
200
|
+
ellipsoid.geodeticSurfaceNormal(origin, up);
|
|
201
|
+
north.copy(up).cross(east);
|
|
202
|
+
const { down, west, south } = scratchAxisVectors;
|
|
203
|
+
down.copy(up).scale(-1);
|
|
204
|
+
west.copy(east).scale(-1);
|
|
205
|
+
south.copy(north).scale(-1);
|
|
206
|
+
firstAxisVector = scratchAxisVectors[firstAxis];
|
|
207
|
+
secondAxisVector = scratchAxisVectors[secondAxis];
|
|
208
|
+
thirdAxisVector = scratchAxisVectors[thirdAxis];
|
|
209
|
+
}
|
|
210
|
+
result[0] = firstAxisVector.x;
|
|
211
|
+
result[1] = firstAxisVector.y;
|
|
212
|
+
result[2] = firstAxisVector.z;
|
|
213
|
+
result[3] = 0;
|
|
214
|
+
result[4] = secondAxisVector.x;
|
|
215
|
+
result[5] = secondAxisVector.y;
|
|
216
|
+
result[6] = secondAxisVector.z;
|
|
217
|
+
result[7] = 0;
|
|
218
|
+
result[8] = thirdAxisVector.x;
|
|
219
|
+
result[9] = thirdAxisVector.y;
|
|
220
|
+
result[10] = thirdAxisVector.z;
|
|
221
|
+
result[11] = 0;
|
|
222
|
+
result[12] = origin.x;
|
|
223
|
+
result[13] = origin.y;
|
|
224
|
+
result[14] = origin.z;
|
|
225
|
+
result[15] = 1;
|
|
226
|
+
return result;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/ellipsoid/helpers/scale-to-geodetic-surface.ts
|
|
230
|
+
var import_core3 = require("@math.gl/core");
|
|
231
|
+
var scratchVector4 = new import_core3.Vector3();
|
|
232
|
+
var scaleToGeodeticSurfaceIntersection = new import_core3.Vector3();
|
|
233
|
+
var scaleToGeodeticSurfaceGradient = new import_core3.Vector3();
|
|
234
|
+
function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
|
|
235
|
+
const { oneOverRadii, oneOverRadiiSquared, centerToleranceSquared } = ellipsoid;
|
|
236
|
+
scratchVector4.from(cartesian);
|
|
237
|
+
const positionX = scratchVector4.x;
|
|
238
|
+
const positionY = scratchVector4.y;
|
|
239
|
+
const positionZ = scratchVector4.z;
|
|
240
|
+
const oneOverRadiiX = oneOverRadii.x;
|
|
241
|
+
const oneOverRadiiY = oneOverRadii.y;
|
|
242
|
+
const oneOverRadiiZ = oneOverRadii.z;
|
|
243
|
+
const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;
|
|
244
|
+
const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;
|
|
245
|
+
const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;
|
|
246
|
+
const squaredNorm = x2 + y2 + z2;
|
|
247
|
+
const ratio = Math.sqrt(1 / squaredNorm);
|
|
248
|
+
if (!Number.isFinite(ratio)) {
|
|
249
|
+
return void 0;
|
|
250
|
+
}
|
|
251
|
+
const intersection = scaleToGeodeticSurfaceIntersection;
|
|
252
|
+
intersection.copy(cartesian).scale(ratio);
|
|
253
|
+
if (squaredNorm < centerToleranceSquared) {
|
|
254
|
+
return intersection.to(result);
|
|
255
|
+
}
|
|
256
|
+
const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
|
|
257
|
+
const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
|
|
258
|
+
const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
|
|
259
|
+
const gradient = scaleToGeodeticSurfaceGradient;
|
|
260
|
+
gradient.set(
|
|
261
|
+
intersection.x * oneOverRadiiSquaredX * 2,
|
|
262
|
+
intersection.y * oneOverRadiiSquaredY * 2,
|
|
263
|
+
intersection.z * oneOverRadiiSquaredZ * 2
|
|
264
|
+
);
|
|
265
|
+
let lambda = (1 - ratio) * scratchVector4.len() / (0.5 * gradient.len());
|
|
266
|
+
let correction = 0;
|
|
267
|
+
let xMultiplier;
|
|
268
|
+
let yMultiplier;
|
|
269
|
+
let zMultiplier;
|
|
270
|
+
let func;
|
|
271
|
+
do {
|
|
272
|
+
lambda -= correction;
|
|
273
|
+
xMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredX);
|
|
274
|
+
yMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredY);
|
|
275
|
+
zMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredZ);
|
|
276
|
+
const xMultiplier2 = xMultiplier * xMultiplier;
|
|
277
|
+
const yMultiplier2 = yMultiplier * yMultiplier;
|
|
278
|
+
const zMultiplier2 = zMultiplier * zMultiplier;
|
|
279
|
+
const xMultiplier3 = xMultiplier2 * xMultiplier;
|
|
280
|
+
const yMultiplier3 = yMultiplier2 * yMultiplier;
|
|
281
|
+
const zMultiplier3 = zMultiplier2 * zMultiplier;
|
|
282
|
+
func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1;
|
|
283
|
+
const denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ;
|
|
284
|
+
const derivative = -2 * denominator;
|
|
285
|
+
correction = func / derivative;
|
|
286
|
+
} while (Math.abs(func) > import_core3._MathUtils.EPSILON12);
|
|
287
|
+
return scratchVector4.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/ellipsoid/ellipsoid.ts
|
|
291
|
+
var scratchVector5 = new import_core4.Vector3();
|
|
292
|
+
var scratchNormal = new import_core4.Vector3();
|
|
293
|
+
var scratchK = new import_core4.Vector3();
|
|
294
|
+
var scratchPosition = new import_core4.Vector3();
|
|
295
|
+
var scratchHeight = new import_core4.Vector3();
|
|
296
|
+
var scratchCartesian = new import_core4.Vector3();
|
|
297
|
+
var _Ellipsoid = class {
|
|
298
|
+
constructor(x = 0, y = 0, z = 0) {
|
|
299
|
+
this.centerToleranceSquared = import_core4._MathUtils.EPSILON1;
|
|
300
|
+
(0, import_core4.assert)(x >= 0);
|
|
301
|
+
(0, import_core4.assert)(y >= 0);
|
|
302
|
+
(0, import_core4.assert)(z >= 0);
|
|
303
|
+
this.radii = new import_core4.Vector3(x, y, z);
|
|
304
|
+
this.radiiSquared = new import_core4.Vector3(x * x, y * y, z * z);
|
|
305
|
+
this.radiiToTheFourth = new import_core4.Vector3(x * x * x * x, y * y * y * y, z * z * z * z);
|
|
306
|
+
this.oneOverRadii = new import_core4.Vector3(
|
|
307
|
+
x === 0 ? 0 : 1 / x,
|
|
308
|
+
y === 0 ? 0 : 1 / y,
|
|
309
|
+
z === 0 ? 0 : 1 / z
|
|
310
|
+
);
|
|
311
|
+
this.oneOverRadiiSquared = new import_core4.Vector3(
|
|
312
|
+
x === 0 ? 0 : 1 / (x * x),
|
|
313
|
+
y === 0 ? 0 : 1 / (y * y),
|
|
314
|
+
z === 0 ? 0 : 1 / (z * z)
|
|
315
|
+
);
|
|
316
|
+
this.minimumRadius = Math.min(x, y, z);
|
|
317
|
+
this.maximumRadius = Math.max(x, y, z);
|
|
318
|
+
if (this.radiiSquared.z !== 0) {
|
|
319
|
+
this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;
|
|
320
|
+
}
|
|
321
|
+
Object.freeze(this);
|
|
322
|
+
}
|
|
323
|
+
equals(right) {
|
|
324
|
+
return this === right || Boolean(right && this.radii.equals(right.radii));
|
|
325
|
+
}
|
|
326
|
+
toString() {
|
|
327
|
+
return this.radii.toString();
|
|
328
|
+
}
|
|
329
|
+
cartographicToCartesian(cartographic, result = [0, 0, 0]) {
|
|
330
|
+
const normal = scratchNormal;
|
|
331
|
+
const k = scratchK;
|
|
332
|
+
const [, , height] = cartographic;
|
|
333
|
+
this.geodeticSurfaceNormalCartographic(cartographic, normal);
|
|
334
|
+
k.copy(this.radiiSquared).scale(normal);
|
|
335
|
+
const gamma = Math.sqrt(normal.dot(k));
|
|
336
|
+
k.scale(1 / gamma);
|
|
337
|
+
normal.scale(height);
|
|
338
|
+
k.add(normal);
|
|
339
|
+
return k.to(result);
|
|
340
|
+
}
|
|
341
|
+
cartesianToCartographic(cartesian, result = [0, 0, 0]) {
|
|
342
|
+
scratchCartesian.from(cartesian);
|
|
343
|
+
const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);
|
|
344
|
+
if (!point) {
|
|
345
|
+
return void 0;
|
|
346
|
+
}
|
|
347
|
+
const normal = this.geodeticSurfaceNormal(point, scratchNormal);
|
|
348
|
+
const h = scratchHeight;
|
|
349
|
+
h.copy(scratchCartesian).subtract(point);
|
|
350
|
+
const longitude = Math.atan2(normal.y, normal.x);
|
|
351
|
+
const latitude = Math.asin(normal.z);
|
|
352
|
+
const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);
|
|
353
|
+
return toCartographicFromRadians([longitude, latitude, height], result);
|
|
354
|
+
}
|
|
355
|
+
eastNorthUpToFixedFrame(origin, result = new import_core4.Matrix4()) {
|
|
356
|
+
return localFrameToFixedFrame(this, "east", "north", "up", origin, result);
|
|
357
|
+
}
|
|
358
|
+
localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new import_core4.Matrix4()) {
|
|
359
|
+
return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);
|
|
360
|
+
}
|
|
361
|
+
geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
362
|
+
return scratchVector5.from(cartesian).normalize().to(result);
|
|
363
|
+
}
|
|
364
|
+
geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {
|
|
365
|
+
const cartographicVectorRadians = fromCartographicToRadians(cartographic);
|
|
366
|
+
const longitude = cartographicVectorRadians[0];
|
|
367
|
+
const latitude = cartographicVectorRadians[1];
|
|
368
|
+
const cosLatitude = Math.cos(latitude);
|
|
369
|
+
scratchVector5.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude)).normalize();
|
|
370
|
+
return scratchVector5.to(result);
|
|
371
|
+
}
|
|
372
|
+
geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {
|
|
373
|
+
return scratchVector5.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
|
|
374
|
+
}
|
|
375
|
+
scaleToGeodeticSurface(cartesian, result) {
|
|
376
|
+
return scaleToGeodeticSurface(cartesian, this, result);
|
|
377
|
+
}
|
|
378
|
+
scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {
|
|
379
|
+
scratchPosition.from(cartesian);
|
|
380
|
+
const positionX = scratchPosition.x;
|
|
381
|
+
const positionY = scratchPosition.y;
|
|
382
|
+
const positionZ = scratchPosition.z;
|
|
383
|
+
const oneOverRadiiSquared = this.oneOverRadiiSquared;
|
|
384
|
+
const beta = 1 / Math.sqrt(
|
|
385
|
+
positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z
|
|
386
|
+
);
|
|
387
|
+
return scratchPosition.multiplyScalar(beta).to(result);
|
|
388
|
+
}
|
|
389
|
+
transformPositionToScaledSpace(position, result = [0, 0, 0]) {
|
|
390
|
+
return scratchPosition.from(position).scale(this.oneOverRadii).to(result);
|
|
391
|
+
}
|
|
392
|
+
transformPositionFromScaledSpace(position, result = [0, 0, 0]) {
|
|
393
|
+
return scratchPosition.from(position).scale(this.radii).to(result);
|
|
394
|
+
}
|
|
395
|
+
getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {
|
|
396
|
+
(0, import_core4.assert)((0, import_core4.equals)(this.radii.x, this.radii.y, import_core4._MathUtils.EPSILON15));
|
|
397
|
+
(0, import_core4.assert)(this.radii.z > 0);
|
|
398
|
+
scratchPosition.from(position);
|
|
399
|
+
const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);
|
|
400
|
+
if (Math.abs(z) >= this.radii.z - buffer) {
|
|
401
|
+
return void 0;
|
|
402
|
+
}
|
|
403
|
+
return scratchPosition.set(0, 0, z).to(result);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
var Ellipsoid = _Ellipsoid;
|
|
407
|
+
Ellipsoid.WGS84 = new _Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
|