@wemap/geo 7.3.0 → 7.3.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.
- package/package.json +2 -2
- package/src/coordinates/GeoRef.js +10 -6
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/geo"
|
|
13
13
|
},
|
|
14
14
|
"name": "@wemap/geo",
|
|
15
|
-
"version": "7.3.
|
|
15
|
+
"version": "7.3.1",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
18
18
|
},
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@wemap/logger": "^7.0.0",
|
|
31
31
|
"@wemap/maths": "^7.0.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "e5431db888821781448e7e05b047e2f4a5d8a1ce"
|
|
34
34
|
}
|
|
@@ -8,10 +8,10 @@ class GeoRef {
|
|
|
8
8
|
origin;
|
|
9
9
|
|
|
10
10
|
/** @type {number} */
|
|
11
|
-
scale;
|
|
11
|
+
scale = 1;
|
|
12
12
|
|
|
13
13
|
/** @type {number} */
|
|
14
|
-
heading;
|
|
14
|
+
heading = 0;
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -19,8 +19,10 @@ class GeoRef {
|
|
|
19
19
|
* @returns {Coordinates}
|
|
20
20
|
*/
|
|
21
21
|
localToWorld(localPosition) {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
22
|
+
const localPositionScaled = Vector3.multiplyScalar(localPosition, this.scale);
|
|
23
|
+
const rotationOffset = Quaternion.fromAxisAngle([0, 0, 1], this.heading);
|
|
24
|
+
const ecefToEnuRotationOrigin = Quaternion.multiply(rotationOffset, this.origin.ecefToEnuRotation);
|
|
25
|
+
const ecefTranslation = Quaternion.rotate(ecefToEnuRotationOrigin, localPositionScaled);
|
|
24
26
|
const ecef = Vector3.add(this.origin.ecef, ecefTranslation);
|
|
25
27
|
return Coordinates.fromECEF(ecef);
|
|
26
28
|
}
|
|
@@ -30,9 +32,11 @@ class GeoRef {
|
|
|
30
32
|
* @returns {number[]} localPosition in ENU frame
|
|
31
33
|
*/
|
|
32
34
|
worldToLocal(coords) {
|
|
33
|
-
const
|
|
35
|
+
const rotationOffset = Quaternion.fromAxisAngle([0, 0, 1], -this.heading);
|
|
36
|
+
const enuToEcefRotationOrigin = Quaternion.multiply(this.origin.enuToEcefRotation, rotationOffset);
|
|
34
37
|
const ecefTranslation = Vector3.subtract(coords.ecef, this.origin.ecef);
|
|
35
|
-
|
|
38
|
+
const ecefTranslationScaled = Vector3.multiplyScalar(ecefTranslation, 1 / this.scale);
|
|
39
|
+
return Quaternion.rotate(enuToEcefRotationOrigin, ecefTranslationScaled);
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
|