@wemap/maths 2.7.0 → 2.7.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/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/maths"
13
13
  },
14
14
  "name": "@wemap/maths",
15
- "version": "2.7.0",
15
+ "version": "2.7.2",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -26,5 +26,5 @@
26
26
  "wemap"
27
27
  ],
28
28
  "license": "ISC",
29
- "gitHead": "6a8ce3404ef84070ad5210c7cd50ee9f4807afc1"
29
+ "gitHead": "ec928b7890e3c37be2a32b1ba1c108aeba9e15b7"
30
30
  }
package/src/Matrix.js CHANGED
@@ -2,15 +2,6 @@
2
2
  /* eslint max-depth: 0 */
3
3
  class Matrix {
4
4
 
5
- static identity4() {
6
- return [
7
- [1, 0, 0, 0],
8
- [0, 1, 0, 0],
9
- [0, 0, 1, 0],
10
- [0, 0, 0, 1]
11
- ];
12
- }
13
-
14
5
  static add(a, b) {
15
6
  const aNumRows = a.length;
16
7
  const aNumCols = a[0].length;
package/src/Matrix3.js CHANGED
@@ -2,6 +2,14 @@ import Matrix from './Matrix';
2
2
 
3
3
  class Matrix3 extends Matrix {
4
4
 
5
+ static get identity() {
6
+ return [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
7
+ }
8
+
9
+ static get zeros() {
10
+ return [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
11
+ }
12
+
5
13
  static add(m1, m2) {
6
14
  return [
7
15
  [m1[0][0] + m2[0][0], m1[0][1] + m2[0][1], m1[0][2] + m2[0][2]],
@@ -18,10 +26,6 @@ class Matrix3 extends Matrix {
18
26
  ];
19
27
  }
20
28
 
21
- static zeros() {
22
- return [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
23
- }
24
-
25
29
  static multiplyScalar(m, s) {
26
30
  return [
27
31
  [m[0][0] * s, m[0][1] * s, m[0][2] * s],
@@ -22,6 +22,22 @@ const v1 = [1, 2, 3];
22
22
 
23
23
  describe('Matrix3', () => {
24
24
 
25
+ it('identity', () => {
26
+ expect(Matrix3.identity).deep.equal([
27
+ [1, 0, 0],
28
+ [0, 1, 0],
29
+ [0, 0, 1]
30
+ ]);
31
+ });
32
+
33
+ it('zeros', () => {
34
+ expect(Matrix3.zeros).deep.equal([
35
+ [0, 0, 0],
36
+ [0, 0, 0],
37
+ [0, 0, 0]
38
+ ]);
39
+ });
40
+
25
41
  it('add', () => {
26
42
  const result = Matrix3.add(m1, m1);
27
43
  expect(result).deep.equal([
package/src/Matrix4.js CHANGED
@@ -2,6 +2,15 @@ import Matrix from './Matrix';
2
2
 
3
3
  class Matrix4 extends Matrix {
4
4
 
5
+ static get identity() {
6
+ return [
7
+ [1, 0, 0, 0],
8
+ [0, 1, 0, 0],
9
+ [0, 0, 1, 0],
10
+ [0, 0, 0, 1]
11
+ ];
12
+ }
13
+
5
14
  static add(m1, m2) {
6
15
  return [
7
16
  [m1[0][0] + m2[0][0], m1[0][1] + m2[0][1], m1[0][2] + m2[0][2], m1[0][3] + m2[0][3]],
@@ -18,6 +18,15 @@ const m2 = [
18
18
 
19
19
  describe('Matrix4', () => {
20
20
 
21
+ it('identity', () => {
22
+ expect(Matrix4.identity).deep.equal([
23
+ [1, 0, 0, 0],
24
+ [0, 1, 0, 0],
25
+ [0, 0, 1, 0],
26
+ [0, 0, 0, 1]
27
+ ]);
28
+ });
29
+
21
30
  it('add', () => {
22
31
  const result = Matrix4.add(m1, m2);
23
32
  expect(result).deep.equal([