@wemap/maths 3.1.15 → 3.2.3

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/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import Matrix from './src/Matrix';
2
- import Matrix3 from './src/Matrix3';
3
- import Matrix4 from './src/Matrix4';
4
- import Point2 from './src/Point2';
5
- import Polygon from './src/Polygon';
6
- import Quaternion from './src/Quaternion';
7
- import Rotations from './src/Rotations';
8
- import Utils from './src/Utils';
9
- import Vector from './src/Vector';
10
- import Vector3 from './src/Vector3';
1
+ import Matrix from './src/Matrix.js';
2
+ import Matrix3 from './src/Matrix3.js';
3
+ import Matrix4 from './src/Matrix4.js';
4
+ import Point2 from './src/Point2.js';
5
+ import Polygon from './src/Polygon.js';
6
+ import Quaternion from './src/Quaternion.js';
7
+ import Rotations from './src/Rotations.js';
8
+ import Utils from './src/Utils.js';
9
+ import Vector from './src/Vector.js';
10
+ import Vector3 from './src/Vector3.js';
11
11
 
12
12
  const {
13
13
  deg2rad, diffAngle, positiveMod, rad2deg
package/package.json CHANGED
@@ -12,19 +12,18 @@
12
12
  "directory": "packages/maths"
13
13
  },
14
14
  "name": "@wemap/maths",
15
- "version": "3.1.15",
15
+ "version": "3.2.3",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
19
19
  "homepage": "https://github.com/wemap/wemap-modules-js#readme",
20
- "scripts": {
21
- "test": "mocha -r esm \"src/**/*.spec.js\""
22
- },
20
+ "scripts": {},
21
+ "type": "module",
23
22
  "keywords": [
24
23
  "utils",
25
24
  "maths",
26
25
  "wemap"
27
26
  ],
28
27
  "license": "ISC",
29
- "gitHead": "44d9ad40afa3e6522a01bc86891082a753199f9a"
28
+ "gitHead": "f7075f59fc3227c7f4cb7f1fa8cc69b98705364e"
30
29
  }
@@ -1,6 +1,8 @@
1
+ import chai from 'chai';
1
2
 
2
- import { expect } from 'chai';
3
- import Matrix from './Matrix';
3
+ import Matrix from './Matrix.js';
4
+
5
+ const { expect } = chai;
4
6
 
5
7
  const m1 = [
6
8
  [1, 2, 3, 4],
package/src/Matrix3.js CHANGED
@@ -1,4 +1,4 @@
1
- import Matrix from './Matrix';
1
+ import Matrix from './Matrix.js';
2
2
 
3
3
  class Matrix3 extends Matrix {
4
4
 
@@ -1,9 +1,9 @@
1
1
  import chai from 'chai';
2
2
  import chaiAlmost from 'chai-almost';
3
3
 
4
- import Matrix3 from './Matrix3';
4
+ import Matrix3 from './Matrix3.js';
5
5
 
6
- const expect = chai.expect;
6
+ const { expect } = chai;
7
7
  chai.use(chaiAlmost());
8
8
 
9
9
  const m1 = [
package/src/Matrix4.js CHANGED
@@ -1,4 +1,4 @@
1
- import Matrix from './Matrix';
1
+ import Matrix from './Matrix.js';
2
2
 
3
3
  class Matrix4 extends Matrix {
4
4
 
@@ -1,6 +1,8 @@
1
- import { expect } from 'chai';
1
+ import chai from 'chai';
2
2
 
3
- import Matrix4 from './Matrix4';
3
+ import Matrix4 from './Matrix4.js';
4
+
5
+ const { expect } = chai;
4
6
 
5
7
  const m1 = [
6
8
  [1, 2, 3, 4],
package/src/Polygon.js CHANGED
@@ -1,4 +1,4 @@
1
- import Point2 from './Point2';
1
+ import Point2 from './Point2.js';
2
2
 
3
3
  class Polygon {
4
4
 
package/src/Quaternion.js CHANGED
@@ -1,7 +1,19 @@
1
- import Vector3 from './Vector3';
1
+ import Vector3 from './Vector3.js';
2
2
 
3
3
  class Quaternion {
4
4
 
5
+ static ROTX_PI2 = this.rotX(Math.PI / 2);
6
+ static ROTX_PI = this.rotX(Math.PI);
7
+ static ROTX_MPI2 = this.rotX(-Math.PI / 2);
8
+
9
+ static ROTY_PI2 = this.rotY(Math.PI / 2);
10
+ static ROTY_PI = this.rotY(Math.PI);
11
+ static ROTY_MPI2 = this.rotY(-Math.PI / 2);
12
+
13
+ static ROTZ_PI2 = this.rotZ(Math.PI / 2);
14
+ static ROTZ_PI = this.rotZ(Math.PI);
15
+ static ROTZ_MPI2 = this.rotZ(-Math.PI / 2);
16
+
5
17
  static get identity() {
6
18
  return [1, 0, 0, 0];
7
19
  }
@@ -50,6 +62,30 @@ class Quaternion {
50
62
  return [Math.cos(angle / 2), axis[0] * s, axis[1] * s, axis[2] * s];
51
63
  }
52
64
 
65
+ /**
66
+ * Rotation around x-axis
67
+ * @param {Number} angle in radians
68
+ */
69
+ static rotX(angle) {
70
+ return this.fromAxisAngle([1, 0, 0], angle);
71
+ }
72
+
73
+ /**
74
+ * Rotation around x-axis
75
+ * @param {Number} angle in radians
76
+ */
77
+ static rotY(angle) {
78
+ return this.fromAxisAngle([0, 1, 0], angle);
79
+ }
80
+
81
+ /**
82
+ * Rotation around x-axis
83
+ * @param {Number} angle in radians
84
+ */
85
+ static rotZ(angle) {
86
+ return this.fromAxisAngle([0, 0, 1], angle);
87
+ }
88
+
53
89
  static fromMatrix3(m) {
54
90
  const qw = Math.sqrt(1 + m[0][0] + m[1][1] + m[2][2]) / 2;
55
91
  const qx = (m[1][2] - m[2][1]) / (4 * qw);
@@ -1,10 +1,10 @@
1
1
  import chai from 'chai';
2
2
  import chaiAlmost from 'chai-almost';
3
3
 
4
- import Quaternion from './Quaternion';
5
- import Vector3 from './Vector3';
4
+ import Quaternion from './Quaternion.js';
5
+ import Vector3 from './Vector3.js';
6
6
 
7
- const expect = chai.expect;
7
+ const { expect } = chai;
8
8
  chai.use(chaiAlmost());
9
9
 
10
10
  const q1 = [0.182574185835055, 0.365148371670111, 0.547722557505166, 0.730296743340221];
package/src/Rotations.js CHANGED
@@ -1,4 +1,4 @@
1
- import Utils from './Utils';
1
+ import Utils from './Utils.js';
2
2
 
3
3
  class Rotations {
4
4
 
@@ -1,9 +1,9 @@
1
1
  import chai from 'chai';
2
2
  import chaiAlmost from 'chai-almost';
3
3
 
4
- import Rotations from './Rotations';
4
+ import Rotations from './Rotations.js';
5
5
 
6
- const expect = chai.expect;
6
+ const { expect } = chai;
7
7
  chai.use(chaiAlmost());
8
8
 
9
9
  const q1 = [0.182574185835055, 0.365148371670111, 0.547722557505166, 0.730296743340221];
package/src/Utils.spec.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import chai from 'chai';
2
2
  import chaiAlmost from 'chai-almost';
3
3
 
4
- import MathUtils from './Utils';
4
+ import MathUtils from './Utils.js';
5
5
 
6
- const expect = chai.expect;
6
+ const { expect } = chai;
7
7
  chai.use(chaiAlmost());
8
8
 
9
9
  describe('MathUtils', () => {
@@ -1,6 +1,8 @@
1
- import { expect } from 'chai';
1
+ import chai from 'chai';
2
2
 
3
- import Vector from './Vector';
3
+ import Vector from './Vector.js';
4
+
5
+ const { expect } = chai;
4
6
 
5
7
  const v1 = [1, 2, 3, 4];
6
8
 
package/src/Vector3.js CHANGED
@@ -1,4 +1,4 @@
1
- import Vector from './Vector';
1
+ import Vector from './Vector.js';
2
2
 
3
3
  class Vector3 extends Vector {
4
4
 
@@ -1,7 +1,8 @@
1
- import { expect } from 'chai';
1
+ import chai from 'chai';
2
2
 
3
- import Vector3 from './Vector3';
3
+ import Vector3 from './Vector3.js';
4
4
 
5
+ const { expect } = chai;
5
6
 
6
7
  const v1 = [1, 2, 3];
7
8
  const v2 = [4, 5, 6];