@math.gl/geospatial 4.0.0-alpha.3 → 4.0.0-beta.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ellipsoid.d.ts","sourceRoot":"","sources":["../../src/ellipsoid/ellipsoid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAA8B,YAAY,
|
|
1
|
+
{"version":3,"file":"ellipsoid.d.ts","sourceRoot":"","sources":["../../src/ellipsoid/ellipsoid.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,OAAO,EAAE,OAAO,EAA8B,YAAY,EAAO,MAAM,eAAe,CAAC;AAK/F,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,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAuB;IAC9D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IAEtC,4FAA4F;gBAChF,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;;IAqC3C,2EAA2E;IAC3E,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;IAIjC,gGAAgG;IAChG,QAAQ,IAAI,MAAM;IAIl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;IACrG,iCAAiC,CAAC,QAAQ,EACxC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,EACpC,MAAM,EAAE,QAAQ,GACf,QAAQ;IACX,iCAAiC,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAgBnE,yGAAyG;IACzG,qBAAqB,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS;IACnF,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAKpD;;0EAEsE;IACtE,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAIxE;yDACqD;IACrD,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAmBrF;kEAC8D;IAC9D,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAI1F;4DACwD;IACxD,gCAAgC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAI5F,wFAAwF;IACxF,qCAAqC,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAM,EAAc,GAC3B,MAAM,EAAE;CAcZ"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Vector3, Matrix4, assert, equals, _MathUtils } from '@math.gl/core';
|
|
3
|
-
import * as vec3 from 'gl-matrix/vec3';
|
|
2
|
+
import { Vector3, Matrix4, assert, equals, _MathUtils, vec3 } from '@math.gl/core';
|
|
4
3
|
import { WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z } from "../constants.js";
|
|
5
4
|
import { fromCartographicToRadians, toCartographicFromRadians } from "../type-utils.js";
|
|
6
5
|
import { localFrameToFixedFrame } from "./helpers/ellipsoid-transform.js";
|
|
@@ -1 +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,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oB;;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
|
+
{"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,EAAoEC,IAApE,QAA+E,eAA/E;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;;AAAA;;AAAA,oDAPGnB,UAAU,CAACoB,QAOd;;AAAA;;AACrCtB,IAAAA,MAAM,CAACmB,CAAC,IAAI,GAAN,CAAN;AACAnB,IAAAA,MAAM,CAACoB,CAAC,IAAI,G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+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, vec3} from '@math.gl/core';\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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,10 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
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
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
18
|
|
|
25
19
|
// src/index.ts
|
|
@@ -32,7 +26,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
32
26
|
|
|
33
27
|
// src/ellipsoid/ellipsoid.ts
|
|
34
28
|
var import_core4 = require("@math.gl/core");
|
|
35
|
-
var vec3 = __toESM(require("gl-matrix/vec3"), 1);
|
|
36
29
|
|
|
37
30
|
// src/constants.ts
|
|
38
31
|
var WGS84_RADIUS_X = 6378137;
|
|
@@ -349,7 +342,7 @@ var _Ellipsoid = class {
|
|
|
349
342
|
h.copy(scratchCartesian).subtract(point);
|
|
350
343
|
const longitude = Math.atan2(normal.y, normal.x);
|
|
351
344
|
const latitude = Math.asin(normal.z);
|
|
352
|
-
const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);
|
|
345
|
+
const height = Math.sign(import_core4.vec3.dot(h, scratchCartesian)) * import_core4.vec3.length(h);
|
|
353
346
|
return toCartographicFromRadians([longitude, latitude, height], result);
|
|
354
347
|
}
|
|
355
348
|
eastNorthUpToFixedFrame(origin, result = new import_core4.Matrix4()) {
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
-
"version": "4.0.0-
|
|
9
|
+
"version": "4.0.0-beta.1",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"webgl",
|
|
12
12
|
"javascript",
|
|
@@ -27,14 +27,20 @@
|
|
|
27
27
|
"types": "dist/index.d.ts",
|
|
28
28
|
"main": "dist/index.cjs",
|
|
29
29
|
"module": "dist/index.js",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"require": "./dist/index.cjs",
|
|
34
|
+
"types": "./dist/index.d.ts"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
30
37
|
"files": [
|
|
31
38
|
"dist",
|
|
32
39
|
"src"
|
|
33
40
|
],
|
|
34
41
|
"dependencies": {
|
|
35
42
|
"@babel/runtime": "^7.12.0",
|
|
36
|
-
"@math.gl/core": "4.0.0-
|
|
37
|
-
"gl-matrix": "^3.4.3"
|
|
43
|
+
"@math.gl/core": "4.0.0-beta.1"
|
|
38
44
|
},
|
|
39
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "5a2364216b6aadbece690e05b9b5b71753aee472"
|
|
40
46
|
}
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
3
3
|
|
|
4
4
|
/* eslint-disable */
|
|
5
|
-
import {Vector3, Matrix4, assert, equals, _MathUtils, NumericArray} from '@math.gl/core';
|
|
6
|
-
// @ts-ignore gl-matrix typings...
|
|
7
|
-
import * as vec3 from 'gl-matrix/vec3';
|
|
5
|
+
import {Vector3, Matrix4, assert, equals, _MathUtils, NumericArray, vec3} from '@math.gl/core';
|
|
8
6
|
|
|
9
7
|
import {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';
|
|
10
8
|
import {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';
|