@math.gl/geospatial 3.5.6 → 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/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +22 -0
- package/dist/ellipsoid/ellipsoid.d.ts +68 -0
- package/dist/ellipsoid/ellipsoid.d.ts.map +1 -0
- package/dist/ellipsoid/ellipsoid.js +142 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts +5 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts.map +1 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.js +125 -0
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.d.ts +3 -0
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.d.ts.map +1 -0
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.js +70 -0
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/ellipsoid/ellipsoid.js +13 -8
- package/dist/es5/ellipsoid/ellipsoid.js.map +1 -1
- package/dist/es5/ellipsoid/helpers/ellipsoid-transform.js.map +1 -1
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js +5 -13
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/type-utils.js +24 -23
- package/dist/es5/type-utils.js.map +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/ellipsoid/ellipsoid.js +23 -8
- 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 +6 -7
- package/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/type-utils.js +24 -22
- package/dist/esm/type-utils.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/type-utils.d.ts +24 -0
- package/dist/type-utils.d.ts.map +1 -0
- package/dist/type-utils.js +96 -0
- package/package.json +5 -5
- package/src/{constants.js → constants.ts} +0 -0
- package/src/ellipsoid/{ellipsoid.js → ellipsoid.ts} +96 -40
- package/src/ellipsoid/helpers/{ellipsoid-transform.js → ellipsoid-transform.ts} +18 -13
- package/src/ellipsoid/helpers/{scale-to-geodetic-surface.js → scale-to-geodetic-surface.ts} +11 -7
- package/src/{index.js → index.ts} +0 -0
- package/src/type-utils.ts +154 -0
- package/dist/es5/ellipsoid/ellipsoid.d.ts +0 -95
- package/dist/es5/index.d.ts +0 -1
- package/dist/es5/type-utils.d.ts +0 -55
- package/dist/esm/ellipsoid/ellipsoid.d.ts +0 -95
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/type-utils.d.ts +0 -55
- package/src/ellipsoid/ellipsoid.d.ts +0 -95
- package/src/index.d.ts +0 -1
- package/src/type-utils.d.ts +0 -55
- package/src/type-utils.js +0 -71
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ellipsoid/helpers/ellipsoid-transform.
|
|
1
|
+
{"version":3,"sources":["../../../../src/ellipsoid/helpers/ellipsoid-transform.ts"],"names":["EPSILON14","scratchOrigin","Vector3","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;;AAIA,IAAMA,SAAS,GAAG,KAAlB;AAEA,IAAMC,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AAGA,IAAMC,0BAA0B,GAAG;AACjC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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 {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\n// Caclulate third axis from given two axii\nconst VECTOR_PRODUCT_LOCAL_FRAME = {\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\ntype Axis = 'up' | 'down' | 'north' | 'east' | 'south' | 'west';\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 default function localFrameToFixedFrame(\n ellipsoid: Ellipsoid,\n firstAxis: Axis,\n secondAxis: Axis,\n thirdAxis: Axis,\n cartesianOrigin: number[],\n result: number[]\n): number[] {\n const thirdAxisInferred =\n VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] &&\n (VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis] as Axis);\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,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -9,25 +7,19 @@ exports.default = scaleToGeodeticSurface;
|
|
|
9
7
|
|
|
10
8
|
var _core = require("@math.gl/core");
|
|
11
9
|
|
|
12
|
-
var vec3 = _interopRequireWildcard(require("gl-matrix/vec3"));
|
|
13
|
-
|
|
14
|
-
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); }
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
10
|
var scratchVector = new _core.Vector3();
|
|
19
11
|
var scaleToGeodeticSurfaceIntersection = new _core.Vector3();
|
|
20
12
|
var scaleToGeodeticSurfaceGradient = new _core.Vector3();
|
|
21
13
|
|
|
22
14
|
function scaleToGeodeticSurface(cartesian, ellipsoid) {
|
|
23
|
-
var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
|
|
15
|
+
var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
24
16
|
var oneOverRadii = ellipsoid.oneOverRadii,
|
|
25
17
|
oneOverRadiiSquared = ellipsoid.oneOverRadiiSquared,
|
|
26
18
|
centerToleranceSquared = ellipsoid.centerToleranceSquared;
|
|
27
19
|
scratchVector.from(cartesian);
|
|
28
|
-
var positionX =
|
|
29
|
-
var positionY =
|
|
30
|
-
var positionZ =
|
|
20
|
+
var positionX = scratchVector.x;
|
|
21
|
+
var positionY = scratchVector.y;
|
|
22
|
+
var positionZ = scratchVector.z;
|
|
31
23
|
var oneOverRadiiX = oneOverRadii.x;
|
|
32
24
|
var oneOverRadiiY = oneOverRadii.y;
|
|
33
25
|
var oneOverRadiiZ = oneOverRadii.z;
|
|
@@ -53,7 +45,7 @@ function scaleToGeodeticSurface(cartesian, ellipsoid) {
|
|
|
53
45
|
var oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
|
|
54
46
|
var gradient = scaleToGeodeticSurfaceGradient;
|
|
55
47
|
gradient.set(intersection.x * oneOverRadiiSquaredX * 2.0, intersection.y * oneOverRadiiSquaredY * 2.0, intersection.z * oneOverRadiiSquaredZ * 2.0);
|
|
56
|
-
var lambda = (1.0 - ratio) *
|
|
48
|
+
var lambda = (1.0 - ratio) * scratchVector.len() / (0.5 * gradient.len());
|
|
57
49
|
var correction = 0.0;
|
|
58
50
|
var xMultiplier;
|
|
59
51
|
var yMultiplier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ellipsoid/helpers/scale-to-geodetic-surface.
|
|
1
|
+
{"version":3,"sources":["../../../../src/ellipsoid/helpers/scale-to-geodetic-surface.ts"],"names":["scratchVector","Vector3","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","_MathUtils","EPSILON12"],"mappings":";;;;;;;AACA;;AAGA,IAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,kCAAkC,GAAG,IAAID,aAAJ,EAA3C;AACA,IAAME,8BAA8B,GAAG,IAAIF,aAAJ,EAAvC;;AAKe,SAASG,sBAAT,CACbC,SADa,EAEbC,SAFa,EAIH;AAAA,MADVC,MACU,uEADS,EACT;AACV,MAAOC,YAAP,GAAoEF,SAApE,CAAOE,YAAP;AAAA,MAAqBC,mBAArB,GAAoEH,SAApE,CAAqBG,mBAArB;AAAA,MAA0CC,sBAA1C,GAAoEJ,SAApE,CAA0CI,sBAA1C;AAEAV,EAAAA,aAAa,CAACW,IAAd,CAAmBN,SAAnB;AAEA,MAAMO,SAAS,GAAGZ,aAAa,CAACa,CAAhC;AACA,MAAMC,SAAS,GAAGd,aAAa,CAACe,CAAhC;AACA,MAAMC,SAAS,GAAGhB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A,SAAOzD,aAAa,CAACiC,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 default 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/es5/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export {default as Ellipsoid} from './ellipsoid/ellipsoid';\nexport {isWGS84} from './type-utils';\n"],"file":"index.js"}
|
package/dist/es5/type-utils.js
CHANGED
|
@@ -15,68 +15,69 @@ var _core = require("@math.gl/core");
|
|
|
15
15
|
|
|
16
16
|
var _constants = require("./constants");
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
function identity(x) {
|
|
19
19
|
return x;
|
|
20
|
-
}
|
|
20
|
+
}
|
|
21
21
|
|
|
22
22
|
var scratchVector = new _core.Vector3();
|
|
23
23
|
|
|
24
|
-
function fromCartographic(cartographic
|
|
25
|
-
var
|
|
24
|
+
function fromCartographic(cartographic) {
|
|
25
|
+
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
26
|
+
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : identity;
|
|
26
27
|
|
|
27
|
-
if (
|
|
28
|
-
result[0] = map(cartographic[0]);
|
|
29
|
-
result[1] = map(cartographic[1]);
|
|
30
|
-
result[2] = cartographic[2];
|
|
31
|
-
} else if ('longitude' in cartographic) {
|
|
28
|
+
if ('longitude' in cartographic) {
|
|
32
29
|
result[0] = map(cartographic.longitude);
|
|
33
30
|
result[1] = map(cartographic.latitude);
|
|
34
31
|
result[2] = cartographic.height;
|
|
35
|
-
} else {
|
|
32
|
+
} else if ('x' in cartographic) {
|
|
36
33
|
result[0] = map(cartographic.x);
|
|
37
34
|
result[1] = map(cartographic.y);
|
|
38
35
|
result[2] = cartographic.z;
|
|
36
|
+
} else {
|
|
37
|
+
result[0] = map(cartographic[0]);
|
|
38
|
+
result[1] = map(cartographic[1]);
|
|
39
|
+
result[2] = cartographic[2];
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
return result;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function fromCartographicToRadians(cartographic) {
|
|
45
|
-
var vector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
46
|
-
return fromCartographic(cartographic, vector, _core.config._cartographicRadians ?
|
|
46
|
+
var vector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
47
|
+
return fromCartographic(cartographic, vector, _core.config._cartographicRadians ? identity : _core.toRadians);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
function fromCartographicToDegrees(cartographic) {
|
|
50
|
-
var vector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
|
51
|
-
return fromCartographic(cartographic, vector, _core.config._cartographicRadians ? _core.toDegrees :
|
|
51
|
+
var vector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
52
|
+
return fromCartographic(cartographic, vector, _core.config._cartographicRadians ? _core.toDegrees : identity);
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
function toCartographic(vector, cartographic) {
|
|
55
|
-
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
|
|
56
|
+
var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : identity;
|
|
56
57
|
|
|
57
|
-
if (
|
|
58
|
-
cartographic[0] = map(vector[0]);
|
|
59
|
-
cartographic[1] = map(vector[1]);
|
|
60
|
-
cartographic[2] = vector[2];
|
|
61
|
-
} else if ('longitude' in cartographic) {
|
|
58
|
+
if ('longitude' in cartographic) {
|
|
62
59
|
cartographic.longitude = map(vector[0]);
|
|
63
60
|
cartographic.latitude = map(vector[1]);
|
|
64
61
|
cartographic.height = vector[2];
|
|
65
|
-
} else {
|
|
62
|
+
} else if ('x' in cartographic) {
|
|
66
63
|
cartographic.x = map(vector[0]);
|
|
67
64
|
cartographic.y = map(vector[1]);
|
|
68
65
|
cartographic.z = vector[2];
|
|
66
|
+
} else {
|
|
67
|
+
cartographic[0] = map(vector[0]);
|
|
68
|
+
cartographic[1] = map(vector[1]);
|
|
69
|
+
cartographic[2] = vector[2];
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
return cartographic;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
function toCartographicFromRadians(vector, cartographic) {
|
|
75
|
-
return toCartographic(vector, cartographic, _core.config._cartographicRadians ?
|
|
76
|
+
return toCartographic(vector, cartographic, _core.config._cartographicRadians ? identity : _core.toDegrees);
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
function toCartographicFromDegrees(vector, cartographic) {
|
|
79
|
-
return toCartographic(vector, cartographic, _core.config._cartographicRadians ? _core.toRadians :
|
|
80
|
+
return toCartographic(vector, cartographic, _core.config._cartographicRadians ? _core.toRadians : identity);
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
function isWGS84(vector) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/type-utils.
|
|
1
|
+
{"version":3,"sources":["../../src/type-utils.ts"],"names":["identity","x","scratchVector","Vector3","fromCartographic","cartographic","result","map","longitude","latitude","height","y","z","fromCartographicToRadians","vector","config","_cartographicRadians","toRadians","fromCartographicToDegrees","toDegrees","toCartographic","toCartographicFromRadians","toCartographicFromDegrees","isWGS84","from","oneOverRadiiSquared","WGS84_CONSTANTS","centerToleranceSquared","x2","y2","z2","Math","abs"],"mappings":";;;;;;;;;;;;;AAIA;;AACA;;AAgBA,SAASA,QAAT,CAAkBC,CAAlB,EAAqC;AACnC,SAAOA,CAAP;AACD;;AAED,IAAMC,aAAa,GAAG,IAAIC,aAAJ,EAAtB;;AAQO,SAASC,gBAAT,CACLC,YADK,EAIK;AAAA,MAFVC,MAEU,uEAFD,EAEC;AAAA,MADVC,GACU,uEADJP,QACI;;AACV,MAAI,eAAeK,YAAnB,EAAiC;AAC/BC,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,GAAG,CAACF,YAAY,CAACG,SAAd,CAAf;AACAF,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,GAAG,CAACF,YAAY,CAACI,QAAd,CAAf;AACAH,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYD,YAAY,CAACK,MAAzB;AACD,GAJD,MAIO,IAAI,OAAOL,YAAX,EAA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BAAmB,CAAC,CAAD,CAAtD;AACA,MAAMI,EAAE,GAAGf,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAAlB,GAAwBW,mBAAmB,CAAC,CAAD,CAAtD;AACA,MAAMK,EAAE,GAAGhB,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAAlB,GAAwBW,mBAAmB,CAAC,CAAD,CAAtD;AACA,SAAOM,IAAI,CAACC,GAAL,CAASJ,EAAE,GAAGC,EAAL,GAAUC,EAAV,GAAe,CAAxB,IAA6BH,sBAApC;AACD","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\nimport type {NumericArray} from '@math.gl/core';\nimport {Vector3, toRadians, toDegrees, config} from '@math.gl/core';\nimport {WGS84_CONSTANTS} from './constants';\n\ntype LngLatHeightObject = {\n longitude: number;\n latitude: number;\n height: number;\n};\n\ntype XYZObject = {\n x: number;\n y: number;\n z: number;\n};\n\ntype Cartographic = LngLatHeightObject | XYZObject | NumericArray;\n\nfunction identity(x: number): number {\n return x;\n}\n\nconst scratchVector = new Vector3();\n\nexport function fromCartographic(cartographic: Cartographic): number[];\nexport function fromCartographic<NumArrayT>(\n cartographic: Cartographic,\n result: NumArrayT,\n map?: (x: number) => number\n): NumArrayT;\nexport function fromCartographic(\n cartographic: Cartographic,\n result = [] as number[],\n map = identity\n): number[] {\n if ('longitude' in cartographic) {\n result[0] = map(cartographic.longitude);\n result[1] = map(cartographic.latitude);\n result[2] = cartographic.height;\n } else if ('x' in cartographic) {\n result[0] = map(cartographic.x);\n result[1] = map(cartographic.y);\n result[2] = cartographic.z;\n } else {\n result[0] = map(cartographic[0]);\n result[1] = map(cartographic[1]);\n result[2] = cartographic[2];\n }\n return result;\n}\n\nexport function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];\nexport function fromCartographicToRadians<TArray>(\n cartographic: Cartographic,\n result: TArray\n): TArray;\nexport function fromCartographicToRadians(\n cartographic: Cartographic,\n vector = [] as number[]\n): number[] {\n return fromCartographic(cartographic, vector, config._cartographicRadians ? identity : toRadians);\n}\n\nexport function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];\nexport function fromCartographicToDegrees<TArray>(\n cartographic: Cartographic,\n result: TArray\n): TArray;\nexport function fromCartographicToDegrees(\n cartographic: Cartographic,\n vector = [] as number[]\n): number[] {\n return fromCartographic(cartographic, vector, config._cartographicRadians ? toDegrees : identity);\n}\n\nexport function toCartographic<T extends Cartographic>(\n vector: Readonly<NumericArray>,\n cartographic: T,\n map: (x: number) => number = identity\n): T {\n if ('longitude' in cartographic) {\n cartographic.longitude = map(vector[0]);\n cartographic.latitude = map(vector[1]);\n cartographic.height = vector[2];\n } else if ('x' in cartographic) {\n cartographic.x = map(vector[0]);\n cartographic.y = map(vector[1]);\n cartographic.z = vector[2];\n } else {\n cartographic[0] = map(vector[0]);\n cartographic[1] = map(vector[1]);\n cartographic[2] = vector[2];\n }\n return cartographic;\n}\n\nexport function toCartographicFromRadians<T extends Cartographic>(\n vector: Readonly<NumericArray>,\n cartographic: T\n): T {\n return toCartographic(vector, cartographic, config._cartographicRadians ? identity : toDegrees);\n}\n\nexport function toCartographicFromDegrees<T extends Cartographic>(\n vector: Readonly<NumericArray>,\n cartographic: T\n): T {\n return toCartographic(vector, cartographic, config._cartographicRadians ? toRadians : identity);\n}\n\n// Estimates if a vector is close to the surface of the WGS84 Ellipsoid\nexport function isWGS84(vector: Readonly<NumericArray>): boolean {\n if (!vector) {\n return false;\n }\n scratchVector.from(vector);\n const {oneOverRadiiSquared, centerToleranceSquared} = WGS84_CONSTANTS;\n const x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];\n const y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];\n const z2 = vector[2] * vector[2] * oneOverRadiiSquared[2];\n return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;\n}\n\n/*\n\nexport function fromCartographic(cartographic: Cartographic, result?: number[]): number[];\nexport function fromCartographic(cartographic: Cartographic, result: TypedArray): TypedArray;\nexport function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];\nexport function fromCartographicToRadians(\n cartographic: Cartographic,\n result: TypedArray\n): TypedArray;\nexport function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];\nexport function fromCartographicToDegrees(\n cartographic: Cartographic,\n result: TypedArray\n): TypedArray;\n\nexport function toCartographic(vector: number[] | TypedArray, result: Cartographic): number[];\nexport function toCartographicFromRadians(\n vector: number[] | TypedArray,\n result: Cartographic\n): number[];\nexport function toCartographicFromDegrees(\n vector: number[] | TypedArray,\n result: Cartographic\n): number[];\n\n// Estimates if a vector is close to the surface of the WGS84 Ellipsoid\nexport function isWGS84(vector: number[] | TypedArray): boolean;\n*/\n"],"file":"type-utils.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants.
|
|
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,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Vector3, Matrix4, assert, equals, _MathUtils } from '@math.gl/core';
|
|
2
3
|
import * as vec3 from 'gl-matrix/vec3';
|
|
3
4
|
import { WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z } from '../constants';
|
|
4
5
|
import { fromCartographicToRadians, toCartographicFromRadians } from '../type-utils';
|
|
@@ -12,12 +13,25 @@ const scratchHeight = new Vector3();
|
|
|
12
13
|
const scratchCartesian = new Vector3();
|
|
13
14
|
let wgs84;
|
|
14
15
|
export default class Ellipsoid {
|
|
15
|
-
static get WGS84() {
|
|
16
|
-
wgs84 = wgs84 || new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
|
|
17
|
-
return wgs84;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
constructor(x = 0.0, y = 0.0, z = 0.0) {
|
|
17
|
+
_defineProperty(this, "radii", void 0);
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "radiiSquared", void 0);
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "radiiToTheFourth", void 0);
|
|
22
|
+
|
|
23
|
+
_defineProperty(this, "oneOverRadii", void 0);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "oneOverRadiiSquared", void 0);
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "minimumRadius", void 0);
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "maximumRadius", void 0);
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "centerToleranceSquared", _MathUtils.EPSILON1);
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "squaredXOverSquaredZ", void 0);
|
|
34
|
+
|
|
21
35
|
assert(x >= 0.0);
|
|
22
36
|
assert(y >= 0.0);
|
|
23
37
|
assert(z >= 0.0);
|
|
@@ -28,7 +42,6 @@ export default class Ellipsoid {
|
|
|
28
42
|
this.oneOverRadiiSquared = new Vector3(x === 0.0 ? 0.0 : 1.0 / (x * x), y === 0.0 ? 0.0 : 1.0 / (y * y), z === 0.0 ? 0.0 : 1.0 / (z * z));
|
|
29
43
|
this.minimumRadius = Math.min(x, y, z);
|
|
30
44
|
this.maximumRadius = Math.max(x, y, z);
|
|
31
|
-
this.centerToleranceSquared = _MathUtils.EPSILON1;
|
|
32
45
|
|
|
33
46
|
if (this.radiiSquared.z !== 0) {
|
|
34
47
|
this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;
|
|
@@ -122,7 +135,7 @@ export default class Ellipsoid {
|
|
|
122
135
|
return scratchPosition.from(position).scale(this.radii).to(result);
|
|
123
136
|
}
|
|
124
137
|
|
|
125
|
-
getSurfaceNormalIntersectionWithZAxis(position, buffer = 0
|
|
138
|
+
getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {
|
|
126
139
|
assert(equals(this.radii.x, this.radii.y, _MathUtils.EPSILON15));
|
|
127
140
|
assert(this.radii.z > 0);
|
|
128
141
|
scratchPosition.from(position);
|
|
@@ -136,4 +149,6 @@ export default class Ellipsoid {
|
|
|
136
149
|
}
|
|
137
150
|
|
|
138
151
|
}
|
|
152
|
+
|
|
153
|
+
_defineProperty(Ellipsoid, "WGS84", new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z));
|
|
139
154
|
//# sourceMappingURL=ellipsoid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ellipsoid/ellipsoid.js"],"names":["Vector3","Matrix4","toRadians","toDegrees","assert","equals","_MathUtils","vec3","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","fromCartographicToRadians","toCartographicFromRadians","scaleToGeodeticSurface","localFrameToFixedFrame","scratchVector","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","wgs84","Ellipsoid","WGS84","constructor","x","y","z","radii","radiiSquared","radiiToTheFourth","oneOverRadii","oneOverRadiiSquared","minimumRadius","Math","min","maximumRadius","max","centerToleranceSquared","EPSILON1","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,SAA1B,EAAqCC,SAArC,EAAgDC,MAAhD,EAAwDC,MAAxD,EAAgEC,UAAhE,QAAiF,eAAjF;AACA,OAAO,KAAKC,IAAZ,MAAsB,gBAAtB;AAEA,SAAQC,cAAR,EAAwBC,cAAxB,EAAwCC,cAAxC,QAA6D,cAA7D;AACA,SAAQC,yBAAR,EAAmCC,yBAAnC,QAAmE,eAAnE;AAEA,OAAOC,sBAAP,MAAmC,qCAAnC;AACA,OAAOC,sBAAP,MAAmC,+BAAnC;AAEA,MAAMC,aAAa,GAAG,IAAIf,OAAJ,EAAtB;AACA,MAAMgB,aAAa,GAAG,IAAIhB,OAAJ,EAAtB;AACA,MAAMiB,QAAQ,GAAG,IAAIjB,OAAJ,EAAjB;AACA,MAAMkB,eAAe,GAAG,IAAIlB,OAAJ,EAAxB;AACA,MAAMmB,aAAa,GAAG,IAAInB,OAAJ,EAAtB;AACA,MAAMoB,gBAAgB,GAAG,IAAIpB,OAAJ,EAAzB;AAEA,IAAIqB,KAAJ;AAKA,eAAe,MAAMC,SAAN,CAAgB;AAEb,aAALC,KAAK,GAAG;AACjBF,IAAAA,KAAK,GAAGA,KAAK,IAAI,IAAIC,SAAJ,CAAcd,cAAd,EAA8BC,cAA9B,EAA8CC,cAA9C,CAAjB;AACA,WAAOW,KAAP;AACD;;AAGDG,EAAAA,WAAW,CAACC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M,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAApB,EAA+B;AAC7D,WAAO9B,eAAe,CAAC4C,IAAhB,CAAqB+B,QAArB,EAA+BvC,KAA/B,CAAqC,KAAK1B,KAA1C,EAAiD+B,EAAjD,CAAoDX,MAApD,CAAP;AACD;;AAGD+C,EAAAA,qCAAqC,CAACF,QAAD,EAAWG,MAAM,GAAG,GAApB,EAAyBhD,MAAM,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAlC,EAA6C;AAEhF5C,IAAAA,MAAM,CAACC,MAAM,CAAC,KAAKuB,KAAL,CAAWH,CAAZ,EAAe,KAAKG,KAAL,CAAWF,CAA1B,EAA6BpB,UAAU,CAAC2F,SAAxC,CAAP,CAAN;AACA7F,IAAAA,MAAM,CAAC,KAAKwB,KAAL,CAAWD,CAAX,GAAe,CAAhB,CAAN;AAEAT,IAAAA,eAAe,CAAC4C,IAAhB,CAAqB+B,QAArB;AACA,UAAMlE,CAAC,GAAGT,eAAe,CAACS,CAAhB,IAAqB,IAAI,KAAKa,oBAA9B,CAAV;;AAEA,QAAIN,IAAI,CAACgE,GAAL,CAASvE,CAAT,KAAe,KAAKC,KAAL,CAAWD,CAAX,GAAeqE,MAAlC,EAA0C;AACxC,aAAOhC,SAAP;AACD;;AAED,WAAO9C,eAAe,CAACkE,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8BzD,CAA9B,EAAiCgC,EAAjC,CAAoCX,MAApC,CAAP;AACD;;AA5L4B","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, toRadians, toDegrees, assert, equals, _MathUtils} 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// A quadratic surface defined in Cartesian coordinates by the equation\n// <code>(x / a)^2 + (y / b)^2 + (z / c)^2 = 1</code>. Primarily used\n// to represent the shape of planetary bodies.\nexport default class Ellipsoid {\n // An Ellipsoid instance initialized to the WGS84 standard.\n static get WGS84() {\n wgs84 = wgs84 || new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);\n return wgs84;\n }\n\n // Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions.\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 this.centerToleranceSquared = _MathUtils.EPSILON1;\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 and returns\n equals(right) {\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() {\n return this.radii.toString();\n }\n\n // Converts the provided cartographic to Cartesian representation.\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, 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, 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 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, 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(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(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, 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, 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, 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, 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(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":["Vector3","Matrix4","assert","equals","_MathUtils","vec3","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","fromCartographicToRadians","toCartographicFromRadians","scaleToGeodeticSurface","localFrameToFixedFrame","scratchVector","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","wgs84","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,SACEA,OADF,EAEEC,OAFF,EAKEC,MALF,EAMEC,MANF,EAOEC,UAPF,QASO,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C,IAAhB,CAAqB+B,QAArB;AACA,UAAMjE,CAAC,GAAGR,eAAe,CAACQ,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,WAAO5C,eAAe,CAACgE,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8BxD,CAA9B,EAAiC+B,EAAjC,CAAoCX,MAApC,CAAP;AACD;;AAzO4B;;gBAAVxB,S,WAEgB,IAAIA,SAAJ,CAAcd,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 {\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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ellipsoid/helpers/ellipsoid-transform.
|
|
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,SAAQA,OAAR,EAAiBC,MAAjB,EAAyBC,MAAM,IAAIC,aAAnC,QAAuD,eAAvD;AAIA,MAAMC,SAAS,GAAG,KAAlB;AAEA,MAAMC,aAAa,GAAG,IAAIL,OAAJ,EAAtB;AAGA,MAAMM,0BAA0B,GAAG;AACjCC,EAAAA,EAAE,EAAE;AACFC,IAAAA,KAAK,EAAE,MADL;AAEFC,IAAAA,KAAK,EAAE,MAFL;AAGFC,IAAAA,IAAI,EAAE,OAHJ;AAIFC,IAAAA,IAAI,EAAE;AAJJ,GAD6B;AAOjCC,EAAAA,IAAI,EAAE;AACJJ,IAAAA,KAAK,EAAE,MADH;AAEJC,IAAAA,KAAK,EAAE,MAFH;AAGJC,IAAAA,IAAI,EAAE,OAHF;AAIJC,IAAAA,IAAI,EAAE;AAJF,GAP2B;AAajCH,EAAAA,KAAK,EAAE;AACLD,IAAAA,EAAE,EAAE,MADC;AAELK,IAAAA,IAAI,EAAE,MAFD;AAGLF,IAAAA,IAAI,EAAE,MAHD;AAILC,IAAAA,IAAI,EAAE;AAJD,GAb0B;AAmBjCF,EAAAA,KAAK,EAAE;AACLF,IAAAA,EAAE,EAAE,MADC;AAELK,IAAAA,IAAI,EAAE,MAFD;AAGLF,IAAAA,IAAI,EAAE,IAHD;AAILC,IAAAA,IAAI,EAAE;AAJD,GAnB0B;AAyBjCD,EAAAA,IAAI,EAAE;AACJH,IAAAA,EAAE,EAAE,OADA;AAEJK,IAAAA,IAAI,EAAE,OAFF;AAGJH,IAAAA,KAAK,EAAE,MAHH;AAIJD,IAAAA,KAAK,EAAE;AAJH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CAACK,CAA7B;AACAR,EAAAA,MAAM,CAAC,CAAD,CAAN,GAAYG,gBAAgB,CAACM,CAA7B;AACAT,EAAAA,MAAM,CAAC,CAAD,CAAN,GAAYG,gBAAgB,CAACS,CAA7B;AACAZ,EAAAA,MAAM,CAAC,CAAD,CAAN,GAAY,GAAZ;AACAA,EAAAA,MAAM,CAAC,CAAD,CAAN,GAAYI,eAAe,CAACI,CAA5B;AACAR,EAAAA,MAAM,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 {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\n// Caclulate third axis from given two axii\nconst VECTOR_PRODUCT_LOCAL_FRAME = {\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\ntype Axis = 'up' | 'down' | 'north' | 'east' | 'south' | 'west';\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 default function localFrameToFixedFrame(\n ellipsoid: Ellipsoid,\n firstAxis: Axis,\n secondAxis: Axis,\n thirdAxis: Axis,\n cartesianOrigin: number[],\n result: number[]\n): number[] {\n const thirdAxisInferred =\n VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] &&\n (VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis] as Axis);\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,18 +1,17 @@
|
|
|
1
|
-
import { Vector3,
|
|
2
|
-
import * as vec3 from 'gl-matrix/vec3';
|
|
1
|
+
import { Vector3, _MathUtils } from '@math.gl/core';
|
|
3
2
|
const scratchVector = new Vector3();
|
|
4
3
|
const scaleToGeodeticSurfaceIntersection = new Vector3();
|
|
5
4
|
const scaleToGeodeticSurfaceGradient = new Vector3();
|
|
6
|
-
export default function scaleToGeodeticSurface(cartesian, ellipsoid, result =
|
|
5
|
+
export default function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
|
|
7
6
|
const {
|
|
8
7
|
oneOverRadii,
|
|
9
8
|
oneOverRadiiSquared,
|
|
10
9
|
centerToleranceSquared
|
|
11
10
|
} = ellipsoid;
|
|
12
11
|
scratchVector.from(cartesian);
|
|
13
|
-
const positionX =
|
|
14
|
-
const positionY =
|
|
15
|
-
const positionZ =
|
|
12
|
+
const positionX = scratchVector.x;
|
|
13
|
+
const positionY = scratchVector.y;
|
|
14
|
+
const positionZ = scratchVector.z;
|
|
16
15
|
const oneOverRadiiX = oneOverRadii.x;
|
|
17
16
|
const oneOverRadiiY = oneOverRadii.y;
|
|
18
17
|
const oneOverRadiiZ = oneOverRadii.z;
|
|
@@ -38,7 +37,7 @@ export default function scaleToGeodeticSurface(cartesian, ellipsoid, result = ne
|
|
|
38
37
|
const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
|
|
39
38
|
const gradient = scaleToGeodeticSurfaceGradient;
|
|
40
39
|
gradient.set(intersection.x * oneOverRadiiSquaredX * 2.0, intersection.y * oneOverRadiiSquaredY * 2.0, intersection.z * oneOverRadiiSquaredZ * 2.0);
|
|
41
|
-
let lambda = (1.0 - ratio) *
|
|
40
|
+
let lambda = (1.0 - ratio) * scratchVector.len() / (0.5 * gradient.len());
|
|
42
41
|
let correction = 0.0;
|
|
43
42
|
let xMultiplier;
|
|
44
43
|
let yMultiplier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/ellipsoid/helpers/scale-to-geodetic-surface.
|
|
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","x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GAAGH,YAAY,GAAGJ,WAApC;AACA,UAAMQ,YAAY,GAAGH,YAAY,GAAGJ,WAApC;AACA,UAAMQ,YAAY,GAAGH,YAAY,GAAGJ,WAApC;AAEAC,IAAAA,IAAI,GAAGzB,EAAE,GAAG0B,YAAL,GAAoBzB,EAAE,GAAG0B,YAAzB,GAAwCzB,EAAE,GAAG0B,YAA7C,GAA4D,GAAnE;AAIA,UAAMI,WAAW,GACfhC,EAAE,GAAG6B,YAAL,GAAoBf,oBAApB,GACAb,EAAE,GAAG6B,YAAL,GAAoBf,oBADpB,GAEAb,EAAE,GAAG6B,YAAL,GAAoBf,oBAHtB;AAKA,UAAMiB,UAAU,GAAG,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 default 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/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":["default","Ellipsoid","isWGS84"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,SAAnB,QAAmC,uBAAnC;AACA,SAAQC,OAAR,QAAsB,cAAtB","sourcesContent":["export {default as Ellipsoid} from './ellipsoid/ellipsoid';\nexport {isWGS84} from './type-utils';\n"],"file":"index.js"}
|