@wemap/maths 10.9.2 → 11.0.0-11.0.0-alpha.11.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.js → index.ts} +2 -1
- package/package.json +14 -5
- package/src/EulerAngles.ts +10 -0
- package/src/{Geometry.js → Geometry.ts} +10 -14
- package/src/{Matrix.js → Matrix.ts} +17 -12
- package/src/{Matrix3.spec.js → Matrix3.spec.ts} +13 -7
- package/src/{Matrix3.js → Matrix3.ts} +46 -21
- package/src/Matrix4.spec.ts +187 -0
- package/src/Matrix4.ts +302 -0
- package/src/{Point2.js → Point2.ts} +4 -2
- package/src/{Polygon.spec.js → Polygon.spec.ts} +3 -2
- package/src/{Polygon.js → Polygon.ts} +4 -3
- package/src/{Quaternion.spec.js → Quaternion.spec.ts} +20 -57
- package/src/{Quaternion.js → Quaternion.ts} +32 -31
- package/src/{Rotations.spec.js → Rotations.spec.ts} +4 -8
- package/src/{Rotations.js → Rotations.ts} +14 -16
- package/src/{Utils.spec.js → Utils.spec.ts} +2 -0
- package/src/{Utils.js → Utils.ts} +10 -23
- package/src/{Vector.spec.js → Vector.spec.ts} +1 -0
- package/src/Vector.ts +10 -0
- package/src/{Vector3.spec.js → Vector3.spec.ts} +4 -2
- package/src/{Vector3.js → Vector3.ts} +11 -10
- package/src/types.ts +21 -0
- package/tsconfig.json +3 -0
- package/vite.config.ts +4 -0
- package/dist/wemap-maths.es.js +0 -1100
- package/dist/wemap-maths.es.js.map +0 -1
- package/index.d.ts +0 -176
- package/src/EulerAngles.js +0 -8
- package/src/Matrix4.js +0 -158
- package/src/Matrix4.spec.js +0 -51
- package/src/Transformation.js +0 -40
- package/src/Transformation.spec.js +0 -79
- package/src/Vector.js +0 -8
- /package/src/{Matrix.spec.js → Matrix.spec.ts} +0 -0
- /package/src/{Point2.spec.js → Point2.spec.ts} +0 -0
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import chai from 'chai';
|
|
2
|
-
import chaiAlmost from 'chai-almost';
|
|
3
|
-
|
|
4
|
-
import Matrix3 from './Matrix3.js';
|
|
5
|
-
import Matrix4 from './Matrix4.js';
|
|
6
|
-
import Transformation from './Transformation.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { expect } = chai;
|
|
10
|
-
chai.use(chaiAlmost());
|
|
11
|
-
|
|
12
|
-
describe('Transformation', () => {
|
|
13
|
-
|
|
14
|
-
let t1, t2;
|
|
15
|
-
let rot1, tr1, rot2, tr2;
|
|
16
|
-
|
|
17
|
-
it('fromPose', () => {
|
|
18
|
-
rot1 = Matrix3.rotX(Math.PI / 2);
|
|
19
|
-
tr1 = [0, 1, 0];
|
|
20
|
-
t1 = Transformation.fromPose(rot1, tr1);
|
|
21
|
-
expect(t1).deep.almost([
|
|
22
|
-
[1, 0, 0, 0],
|
|
23
|
-
[0, 0, -1, 1],
|
|
24
|
-
[0, 1, 0, 0],
|
|
25
|
-
[0, 0, 0, 1]
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
rot2 = Matrix3.multiply(rot1, Matrix3.rotZ(Math.PI / 2));
|
|
29
|
-
tr2 = [2, 1, 0];
|
|
30
|
-
t2 = Transformation.fromPose(rot2, tr2);
|
|
31
|
-
expect(t2).deep.almost([
|
|
32
|
-
[0, -1, 0, 2],
|
|
33
|
-
[0, 0, -1, 1],
|
|
34
|
-
[-1, 0, 0, 0],
|
|
35
|
-
[0, 0, 0, 1]
|
|
36
|
-
]);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('extractRotation', () => {
|
|
40
|
-
expect(Transformation.extractRotation(t1)).deep.almost(rot1);
|
|
41
|
-
expect(Transformation.extractRotation(t2)).deep.almost(rot2);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('extractTranslation', () => {
|
|
45
|
-
expect(Transformation.extractTranslation(t1)).deep.almost(tr1);
|
|
46
|
-
expect(Transformation.extractTranslation(t2)).deep.almost(tr2);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('invert', () => {
|
|
50
|
-
expect(Transformation.invert(t1)).deep.almost([
|
|
51
|
-
[1, 0, 0, 0],
|
|
52
|
-
[0, 0, 1, 0],
|
|
53
|
-
[0, -1, 0, 1],
|
|
54
|
-
[0, 0, 0, 1]
|
|
55
|
-
]);
|
|
56
|
-
|
|
57
|
-
expect(Transformation.invert(t2)).deep.almost([
|
|
58
|
-
[0, 0, -1, 0],
|
|
59
|
-
[-1, 0, 0, 2],
|
|
60
|
-
[0, -1, 0, 1],
|
|
61
|
-
[0, 0, 0, 1]
|
|
62
|
-
]);
|
|
63
|
-
|
|
64
|
-
const tr3 = Transformation.scaleScalar(
|
|
65
|
-
Transformation.fromPose(
|
|
66
|
-
Matrix3.rotY(Math.PI / 2),
|
|
67
|
-
[1, 2, 3]
|
|
68
|
-
), 2);
|
|
69
|
-
const invertTr3 = Transformation.invert(tr3);
|
|
70
|
-
expect(invertTr3).deep.almost([
|
|
71
|
-
[0, 0, -1, 6],
|
|
72
|
-
[0, 1, 0, -4],
|
|
73
|
-
[1, 0, 0, -2],
|
|
74
|
-
[0, 0, 0, 2]
|
|
75
|
-
]);
|
|
76
|
-
expect(Matrix4.multiply(tr3, invertTr3)).deep.almost(Matrix4.identity);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
});
|
package/src/Vector.js
DELETED
|
File without changes
|
|
File without changes
|