@thi.ng/matrices 2.2.12 → 2.2.14

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 (60) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +1 -1
  3. package/add.js +10 -13
  4. package/addn.js +10 -13
  5. package/alignment-quat.js +10 -16
  6. package/api.js +0 -1
  7. package/column.js +21 -13
  8. package/compile/emit.js +20 -3
  9. package/concat.js +4 -11
  10. package/conjugate.js +4 -1
  11. package/constants.js +35 -13
  12. package/determinant.js +51 -27
  13. package/diag.js +12 -11
  14. package/div.js +10 -13
  15. package/divn.js +10 -13
  16. package/fit.js +16 -24
  17. package/frustum.js +38 -28
  18. package/identity.js +12 -8
  19. package/invert.js +100 -45
  20. package/lookat.js +26 -15
  21. package/m22-m23.js +4 -8
  22. package/m23-m22.js +4 -8
  23. package/m23-m44.js +26 -16
  24. package/m33-m44.js +26 -16
  25. package/m44-m33.js +4 -11
  26. package/matn.js +10 -4
  27. package/matv.js +10 -36
  28. package/mixq.js +18 -28
  29. package/mul.js +10 -15
  30. package/mulm.js +67 -45
  31. package/muln.js +10 -13
  32. package/mulq.js +13 -12
  33. package/mulv.js +58 -77
  34. package/mulvm.js +16 -46
  35. package/normal-mat.js +10 -23
  36. package/orthagonal.js +17 -25
  37. package/ortho.js +26 -17
  38. package/outer-product.js +48 -10
  39. package/package.json +10 -7
  40. package/perspective.js +6 -13
  41. package/project.js +20 -51
  42. package/quat-axis-angle.js +13 -23
  43. package/quat-euler.js +16 -18
  44. package/quat-m33.js +29 -21
  45. package/quat-m44.js +36 -22
  46. package/rotation-around-axis.js +27 -32
  47. package/rotation.js +41 -79
  48. package/row.js +12 -13
  49. package/scale-center.js +16 -16
  50. package/scale.js +32 -42
  51. package/set.js +13 -6
  52. package/shear.js +35 -18
  53. package/skew.js +52 -17
  54. package/sub.js +10 -13
  55. package/subn.js +10 -13
  56. package/trace.js +4 -6
  57. package/transform.js +19 -23
  58. package/translation.js +6 -14
  59. package/transpose.js +26 -24
  60. package/viewport.js +9 -16
package/trace.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import { sum } from "@thi.ng/vectors/sum";
2
2
  import { diag } from "./diag.js";
3
- /**
4
- * Returns matrix trace of `m`, i.e. component sum of `diag(m)`.
5
- *
6
- * @param m -
7
- */
8
- export const trace = (m) => sum(diag([], m));
3
+ const trace = (m) => sum(diag([], m));
4
+ export {
5
+ trace
6
+ };
package/transform.js CHANGED
@@ -5,26 +5,22 @@ import { quatToMat44 } from "./quat-m44.js";
5
5
  import { rotation23 } from "./rotation.js";
6
6
  import { scale23, scale44 } from "./scale.js";
7
7
  import { translation23 } from "./translation.js";
8
- /**
9
- * Creates 2x3 TRS transformation matrix from given translation vector,
10
- * rotation angle and scale factor/vector.
11
- *
12
- * @param out -
13
- * @param translate -
14
- * @param rotation -
15
- * @param scale -
16
- */
17
- export const transform23 = (out, translate, rotation, scale) => concat(out, translation23([], translate), rotation23([], rotation), scale23([], scale));
18
- /**
19
- * Creates 4x4 TRS transformation matrix from given translation vector,
20
- * rotation angles (given as 3D vector) and scale factor/vector.
21
- * Internally, uses a quaternion for constructing the rotation matrix
22
- * part. The quaternion is created via {@link quatFromEuler} with ZYX
23
- * ordering.
24
- *
25
- * @param out -
26
- * @param translate -
27
- * @param rotation -
28
- * @param scale -
29
- */
30
- export const transform44 = (out, translate, rotation, scale) => mulM44(out, quatToMat44(out, quatFromEuler("zyx", rotation[2], rotation[1], rotation[0]), translate), scale44([], scale));
8
+ const transform23 = (out, translate, rotation, scale) => concat(
9
+ out,
10
+ translation23([], translate),
11
+ rotation23([], rotation),
12
+ scale23([], scale)
13
+ );
14
+ const transform44 = (out, translate, rotation, scale) => mulM44(
15
+ out,
16
+ quatToMat44(
17
+ out,
18
+ quatFromEuler("zyx", rotation[2], rotation[1], rotation[0]),
19
+ translate
20
+ ),
21
+ scale44([], scale)
22
+ );
23
+ export {
24
+ transform23,
25
+ transform44
26
+ };
package/translation.js CHANGED
@@ -1,15 +1,7 @@
1
1
  import { setC, setC6 } from "@thi.ng/vectors/setc";
2
- /**
3
- * Constructs a 2x3 translation matrix.
4
- *
5
- * @param out -
6
- * @param v -
7
- */
8
- export const translation23 = (m, v) => setC6(m || [], 1, 0, 0, 1, v[0], v[1]);
9
- /**
10
- * Constructs a 4x4 translation matrix.
11
- *
12
- * @param out -
13
- * @param v -
14
- */
15
- export const translation44 = (m, v) => setC(m || [], 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, v[0], v[1], v[2], 1);
2
+ const translation23 = (m, v) => setC6(m || [], 1, 0, 0, 1, v[0], v[1]);
3
+ const translation44 = (m, v) => setC(m || [], 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, v[0], v[1], v[2], 1);
4
+ export {
5
+ translation23,
6
+ translation44
7
+ };
package/transpose.js CHANGED
@@ -1,25 +1,27 @@
1
1
  import { setC, setC4 } from "@thi.ng/vectors/setc";
2
- /**
3
- * Writes transposition of 2x2 matrix `m` to `out`. Creates new matrix
4
- * if `out` is `null`
5
- *
6
- * @param out -
7
- * @param m -
8
- */
9
- export const transpose22 = (out, m) => setC4(out || [], m[0], m[2], m[1], m[3]);
10
- /**
11
- * Writes transposition of 3x3 matrix `m` to `out`. Creates new matrix
12
- * if `out` is `null`
13
- *
14
- * @param out -
15
- * @param m -
16
- */
17
- export const transpose33 = (out, m) => setC(out || [], m[0], m[3], m[6], m[1], m[4], m[7], m[2], m[5], m[8]);
18
- /**
19
- * Writes transposition of 4x4 matrix `m` to `out`. Creates new matrix
20
- * if `out` is `null`
21
- *
22
- * @param out -
23
- * @param m -
24
- */
25
- export const transpose44 = (out, m) => setC(out || [], m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]);
2
+ const transpose22 = (out, m) => setC4(out || [], m[0], m[2], m[1], m[3]);
3
+ const transpose33 = (out, m) => setC(out || [], m[0], m[3], m[6], m[1], m[4], m[7], m[2], m[5], m[8]);
4
+ const transpose44 = (out, m) => setC(
5
+ out || [],
6
+ m[0],
7
+ m[4],
8
+ m[8],
9
+ m[12],
10
+ m[1],
11
+ m[5],
12
+ m[9],
13
+ m[13],
14
+ m[2],
15
+ m[6],
16
+ m[10],
17
+ m[14],
18
+ m[3],
19
+ m[7],
20
+ m[11],
21
+ m[15]
22
+ );
23
+ export {
24
+ transpose22,
25
+ transpose33,
26
+ transpose44
27
+ };
package/viewport.js CHANGED
@@ -1,20 +1,13 @@
1
1
  import { mulM23 } from "./mulm.js";
2
2
  import { scale23 } from "./scale.js";
3
3
  import { translation23 } from "./translation.js";
4
- /**
5
- * Produces a 2x3 viewport matrix to transform projected coordinates to
6
- * screen space.
7
- *
8
- * @param out -
9
- * @param left -
10
- * @param right -
11
- * @param bottom -
12
- * @param top -
13
- */
14
- export const viewport = (out, left, right, bottom, top) => {
15
- const x = (left + right) / 2;
16
- const y = (bottom + top) / 2;
17
- const w = (right - left) / 2;
18
- const h = (top - bottom) / 2;
19
- return mulM23(null, translation23(out, [x, y]), scale23([], [w, h]));
4
+ const viewport = (out, left, right, bottom, top) => {
5
+ const x = (left + right) / 2;
6
+ const y = (bottom + top) / 2;
7
+ const w = (right - left) / 2;
8
+ const h = (top - bottom) / 2;
9
+ return mulM23(null, translation23(out, [x, y]), scale23([], [w, h]));
10
+ };
11
+ export {
12
+ viewport
20
13
  };