@wemap/maths 10.0.0 → 10.3.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.
- package/index.d.ts +4 -2
- package/package.json +2 -2
- package/src/Matrix3.js +9 -3
- package/src/Utils.js +9 -0
package/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ declare module '@wemap/maths' {
|
|
|
27
27
|
export function diffAngleLines(angle1: number, angle2: number): number;
|
|
28
28
|
export function positiveMod(n: number, m: number): number;
|
|
29
29
|
export function rad2deg(angle: number): number;
|
|
30
|
+
export function roundFactor(num: number, factor: number): number;
|
|
30
31
|
export function std(arr: number[]): number;
|
|
31
32
|
export function wrap(n: number, min: number, max: number): number;
|
|
32
33
|
|
|
@@ -90,7 +91,7 @@ declare module '@wemap/maths' {
|
|
|
90
91
|
export class Matrix {
|
|
91
92
|
static concatRow(m1: Matrix_t, m2: Matrix_t): Matrix_t;
|
|
92
93
|
static concatLine(m1: Matrix_t, m2: Matrix_t): Matrix_t;
|
|
93
|
-
static diag(
|
|
94
|
+
static diag(arr: Vector_t): Matrix_t;
|
|
94
95
|
static inverse(m: Matrix_t): Matrix_t;
|
|
95
96
|
static multiply(m1: Matrix_t, m2: Matrix_t): Matrix_t;
|
|
96
97
|
static multiplyScalar(m: Matrix_t, s: number): Matrix_t;
|
|
@@ -99,10 +100,11 @@ declare module '@wemap/maths' {
|
|
|
99
100
|
static transpose(m: Matrix_t): Matrix_t;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
export class Matrix3
|
|
103
|
+
export class Matrix3 {
|
|
103
104
|
static get identity(): Matrix3_t;
|
|
104
105
|
static get zeros(): Matrix3_t;
|
|
105
106
|
|
|
107
|
+
static diag(arr: Vector3_t): Matrix3_t;
|
|
106
108
|
static inverse(q: Matrix3_t): Matrix3_t;
|
|
107
109
|
static multiply(a: Matrix3_t, b: Matrix3_t): Matrix3_t;
|
|
108
110
|
static multiplyScalar(m: Matrix3_t, s: number): Matrix3_t;
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"directory": "packages/maths"
|
|
14
14
|
},
|
|
15
15
|
"name": "@wemap/maths",
|
|
16
|
-
"version": "10.
|
|
16
|
+
"version": "10.3.0",
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/wemap/wemap-modules-js/issues"
|
|
19
19
|
},
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"wemap"
|
|
27
27
|
],
|
|
28
28
|
"license": "ISC",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "2435b4a1c0218f56a87ff1768e197f8cb738aa4d"
|
|
30
30
|
}
|
package/src/Matrix3.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class Matrix3 extends Matrix {
|
|
1
|
+
class Matrix3 {
|
|
4
2
|
|
|
5
3
|
static get identity() {
|
|
6
4
|
return [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
@@ -10,6 +8,14 @@ class Matrix3 extends Matrix {
|
|
|
10
8
|
return [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
|
|
11
9
|
}
|
|
12
10
|
|
|
11
|
+
static diag(arr) {
|
|
12
|
+
return [
|
|
13
|
+
[arr[0], 0, 0],
|
|
14
|
+
[0, arr[1], 0],
|
|
15
|
+
[0, 0, arr[2]]
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
static sum(m1, m2) {
|
|
14
20
|
return [
|
|
15
21
|
[m1[0][0] + m2[0][0], m1[0][1] + m2[0][1], m1[0][2] + m2[0][2]],
|
package/src/Utils.js
CHANGED
|
@@ -79,3 +79,12 @@ export function std(arr) {
|
|
|
79
79
|
const mean = arr.reduce((a, b) => a + b) / n;
|
|
80
80
|
return Math.sqrt(arr.map(x => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / n);
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {number} num
|
|
85
|
+
* @param {number} factor
|
|
86
|
+
* @returns {number}
|
|
87
|
+
*/
|
|
88
|
+
export function roundFactor(num, factor) {
|
|
89
|
+
return Math.round(num / factor) * factor;
|
|
90
|
+
}
|