@wemap/maths 7.0.0 → 7.5.0

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/Quaternion.js +14 -0
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/maths"
13
13
  },
14
14
  "name": "@wemap/maths",
15
- "version": "7.0.0",
15
+ "version": "7.5.0",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -25,5 +25,5 @@
25
25
  "wemap"
26
26
  ],
27
27
  "license": "ISC",
28
- "gitHead": "cfd70d1f998599c53689c1b1996a517247f04dce"
28
+ "gitHead": "a72fe36a5b1444444fa263c51b4d9eaf7284f824"
29
29
  }
package/src/Quaternion.js CHANGED
@@ -105,6 +105,20 @@ class Quaternion {
105
105
  return [qw, qx, qy, qz];
106
106
  }
107
107
 
108
+ static toMatrix3(q) {
109
+ const [w, x, y, z] = q;
110
+
111
+ const wx = w * x, wy = w * y, wz = w * z;
112
+ const xx = x * x, xy = x * y, xz = x * z;
113
+ const yy = y * y, yz = y * z, zz = z * z;
114
+
115
+ return [
116
+ [1 - 2 * (yy + zz), 2 * (xy - wz), 2 * (xz + wy)],
117
+ [2 * (xy + wz), 1 - 2 * (xx + zz), 2 * (yz - wx)],
118
+ [2 * (xz - wy), 2 * (yz + wx), 1 - 2 * (xx + yy)]];
119
+
120
+ }
121
+
108
122
  static wxyz2xyzw(wxyz) {
109
123
  return [wxyz[1], wxyz[2], wxyz[3], wxyz[0]];
110
124
  }