linearly 0.19.0 → 0.20.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.
Files changed (68) hide show
  1. package/README.md +7 -7
  2. package/lib/cjs/demo.d.ts +2 -0
  3. package/lib/cjs/demo.d.ts.map +1 -0
  4. package/lib/cjs/demo.js +7 -0
  5. package/lib/cjs/index.d.ts +9 -45
  6. package/lib/cjs/index.d.ts.map +1 -1
  7. package/lib/cjs/index.js +19 -61
  8. package/lib/cjs/mat2.d.ts +133 -128
  9. package/lib/cjs/mat2.d.ts.map +1 -1
  10. package/lib/cjs/mat2.js +257 -246
  11. package/lib/cjs/mat2d.d.ts +160 -154
  12. package/lib/cjs/mat2d.d.ts.map +1 -1
  13. package/lib/cjs/mat2d.js +425 -418
  14. package/lib/cjs/mat3.d.ts +172 -167
  15. package/lib/cjs/mat3.d.ts.map +1 -1
  16. package/lib/cjs/mat3.js +512 -506
  17. package/lib/cjs/mat4.d.ts +391 -372
  18. package/lib/cjs/mat4.d.ts.map +1 -1
  19. package/lib/cjs/mat4.js +1338 -1336
  20. package/lib/cjs/quat.d.ts +239 -234
  21. package/lib/cjs/quat.d.ts.map +1 -1
  22. package/lib/cjs/quat.js +494 -490
  23. package/lib/cjs/scalar.d.ts +204 -199
  24. package/lib/cjs/scalar.d.ts.map +1 -1
  25. package/lib/cjs/scalar.js +323 -317
  26. package/lib/cjs/vec2.d.ts +307 -302
  27. package/lib/cjs/vec2.d.ts.map +1 -1
  28. package/lib/cjs/vec2.js +612 -604
  29. package/lib/cjs/vec3.d.ts +359 -354
  30. package/lib/cjs/vec3.d.ts.map +1 -1
  31. package/lib/cjs/vec3.js +760 -755
  32. package/lib/cjs/vec4.d.ts +301 -296
  33. package/lib/cjs/vec4.d.ts.map +1 -1
  34. package/lib/cjs/vec4.js +691 -681
  35. package/lib/esm/demo.d.ts +2 -0
  36. package/lib/esm/demo.d.ts.map +1 -0
  37. package/lib/esm/demo.js +5 -0
  38. package/lib/esm/index.d.ts +9 -45
  39. package/lib/esm/index.d.ts.map +1 -1
  40. package/lib/esm/index.js +10 -38
  41. package/lib/esm/mat2.d.ts +133 -128
  42. package/lib/esm/mat2.d.ts.map +1 -1
  43. package/lib/esm/mat2.js +260 -230
  44. package/lib/esm/mat2d.d.ts +160 -154
  45. package/lib/esm/mat2d.d.ts.map +1 -1
  46. package/lib/esm/mat2d.js +424 -393
  47. package/lib/esm/mat3.d.ts +172 -167
  48. package/lib/esm/mat3.d.ts.map +1 -1
  49. package/lib/esm/mat3.js +511 -479
  50. package/lib/esm/mat4.d.ts +391 -372
  51. package/lib/esm/mat4.d.ts.map +1 -1
  52. package/lib/esm/mat4.js +1337 -1290
  53. package/lib/esm/quat.d.ts +239 -234
  54. package/lib/esm/quat.d.ts.map +1 -1
  55. package/lib/esm/quat.js +493 -468
  56. package/lib/esm/scalar.d.ts +204 -199
  57. package/lib/esm/scalar.d.ts.map +1 -1
  58. package/lib/esm/scalar.js +317 -279
  59. package/lib/esm/vec2.d.ts +307 -302
  60. package/lib/esm/vec2.d.ts.map +1 -1
  61. package/lib/esm/vec2.js +611 -543
  62. package/lib/esm/vec3.d.ts +359 -354
  63. package/lib/esm/vec3.d.ts.map +1 -1
  64. package/lib/esm/vec3.js +759 -692
  65. package/lib/esm/vec4.d.ts +301 -296
  66. package/lib/esm/vec4.d.ts.map +1 -1
  67. package/lib/esm/vec4.js +690 -626
  68. package/package.json +1 -1
package/README.md CHANGED
@@ -26,14 +26,14 @@ vec2.scale(out, out, 3)
26
26
 
27
27
  ```ts
28
28
  // In linearly, you can simply write like this:
29
- import {mat2d, type Mat2d, vec3} from 'linearly'
29
+ import {mat2d, vec3} from 'linearly'
30
30
 
31
31
  const dir = vec3.normalize([2, 1, 3])
32
32
  let out = vec3.cross(dir, [0, 1, 0])
33
33
  out = vec3.scale(out, 3)
34
34
 
35
35
  // As the values of Linearly are plain 1D arrays, you can initialize a vector by either way.
36
- const a: Vec2 = [1, 2]
36
+ const a: vec2 = [1, 2]
37
37
  const b = vec2.of(1, 2)
38
38
 
39
39
  // But since vector and matrix are immutable and annotated with readonly flags, a mutation such as below are handled as an error in TypeScript.
@@ -42,7 +42,7 @@ a[0] = 3
42
42
  // Cannot assign to '0' because it is a read-only property.
43
43
 
44
44
  // Some constants such as mat2.identity are also readonly and defined as frozen array (applied Object.freeze). You can use `clone` to mutate them.
45
- const m: Mat2d = mat2d.clone(mat2d.ident)
45
+ const m = mat2d.clone(mat2d.ident)
46
46
  m[4] *= 2.0
47
47
  m[5] = -4.5
48
48
  ```
@@ -58,10 +58,10 @@ In addition to functions that can be found on [glMatrix docs](https://glmatrix.n
58
58
  The names of modules are derived from glMatrix.
59
59
 
60
60
  - `scalar`: A single number
61
- - `mat2`: 2D linear transformation (rotation + scale + skew)
62
- - `mat2d`: 2D affine transformation, omitting redundant third rows, which is always set to `[0, 0, 1]` (translation + rotation + scale + skew)
63
- - `mat3`: 2D homogeneous transformation (translation + rotation + scale + skew + perspective)
64
- - `mat4`: 3D affine transformation
61
+ - `mat2`: 2D linear transformation (rotation, scaling, skewing)
62
+ - `mat2d`: 2D affine transformation, omitting redundant third rows, which is always set to `[0, 0, 1]` (translation, rotation, scaling, skewing)
63
+ - `mat3`: 2D affine transformation (translation, rotation, scaling, skewing)
64
+ - `mat4`: 3D transformation
65
65
  - `quat`: 3D rotation
66
66
 
67
67
  See the [Full API documentation](https://baku89.github.io/linearly) for further information.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=demo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../../src/demo.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _1 = require(".");
4
+ const x = _1.vec2.add([1, 2], [3, 4]);
5
+ const y = _1.vec2.clone(x);
6
+ y[0] = 3;
7
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVtby5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kZW1vLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsd0JBQXNCO0FBRXRCLE1BQU0sQ0FBQyxHQUFTLE9BQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsQ0FBQTtBQUV4QyxNQUFNLENBQUMsR0FBRyxPQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFBO0FBRXZCLENBQUMsQ0FBQyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUEifQ==
@@ -1,46 +1,10 @@
1
- /**
2
- * Represents a single number.
3
- */
4
- export * as scalar from './scalar';
5
- /**
6
- * Represents 2D vector.
7
- */
8
- export * as vec2 from './vec2';
9
- export type { Vec2 } from './vec2';
10
- /**
11
- * Represents 3D vector.
12
- */
13
- export * as vec3 from './vec3';
14
- export type { Vec3 } from './vec3';
15
- /**
16
- * Represents 4D vector.
17
- */
18
- export * as vec4 from './vec4';
19
- export type { Vec4 } from './vec4';
20
- /**
21
- * Represents 2D linear transformation (rotation, scaling, skewing).
22
- */
23
- export * as mat2 from './mat2';
24
- export type { Mat2 } from './mat2';
25
- /**
26
- * Represents 2D affine transformation (translation, rotation, scaling, skewing), omitting reduction thrid row which is always set to `[0, 0, 1]`. The order of six elements is the same as CSS transform matrix.
27
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
28
- */
29
- export * as mat2d from './mat2d';
30
- export type { Mat2d } from './mat2d';
31
- /**
32
- * Rpresents 2D homogeneous transformation (translation, rotation, scaling, skewing, perspective).
33
- */
34
- export * as mat3 from './mat3';
35
- export type { Mat3 } from './mat3';
36
- /**
37
- * Represents 3D affine transformation (translation, rotation, scaling, skewing).
38
- */
39
- export * as mat4 from './mat4';
40
- export type { Mat4 } from './mat4';
41
- /**
42
- * Represents rotation in 3D space.
43
- */
44
- export * as quat from './quat';
45
- export type { Quat } from './quat';
1
+ export { scalar } from './scalar';
2
+ export { vec2 } from './vec2';
3
+ export { vec3 } from './vec3';
4
+ export { vec4 } from './vec4';
5
+ export { mat2 } from './mat2';
6
+ export { mat2d } from './mat2d';
7
+ export { mat3 } from './mat3';
8
+ export { mat4 } from './mat4';
9
+ export { quat } from './quat';
46
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAElC;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,YAAY,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAEhC;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,YAAY,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAEhC;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,YAAY,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAEhC;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,YAAY,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAEhC;;;GAGG;AACH,OAAO,KAAK,KAAK,MAAM,SAAS,CAAA;AAChC,YAAY,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAElC;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,YAAY,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAEhC;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,YAAY,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAEhC;;GAEG;AACH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,YAAY,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA"}
package/lib/cjs/index.js CHANGED
@@ -1,64 +1,22 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.quat = exports.mat4 = exports.mat3 = exports.mat2d = exports.mat2 = exports.vec4 = exports.vec3 = exports.vec2 = exports.scalar = void 0;
27
- /**
28
- * Represents a single number.
29
- */
30
- exports.scalar = __importStar(require("./scalar"));
31
- /**
32
- * Represents 2D vector.
33
- */
34
- exports.vec2 = __importStar(require("./vec2"));
35
- /**
36
- * Represents 3D vector.
37
- */
38
- exports.vec3 = __importStar(require("./vec3"));
39
- /**
40
- * Represents 4D vector.
41
- */
42
- exports.vec4 = __importStar(require("./vec4"));
43
- /**
44
- * Represents 2D linear transformation (rotation, scaling, skewing).
45
- */
46
- exports.mat2 = __importStar(require("./mat2"));
47
- /**
48
- * Represents 2D affine transformation (translation, rotation, scaling, skewing), omitting reduction thrid row which is always set to `[0, 0, 1]`. The order of six elements is the same as CSS transform matrix.
49
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
50
- */
51
- exports.mat2d = __importStar(require("./mat2d"));
52
- /**
53
- * Rpresents 2D homogeneous transformation (translation, rotation, scaling, skewing, perspective).
54
- */
55
- exports.mat3 = __importStar(require("./mat3"));
56
- /**
57
- * Represents 3D affine transformation (translation, rotation, scaling, skewing).
58
- */
59
- exports.mat4 = __importStar(require("./mat4"));
60
- /**
61
- * Represents rotation in 3D space.
62
- */
63
- exports.quat = __importStar(require("./quat"));
64
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTs7R0FFRztBQUNILG1EQUFrQztBQUVsQzs7R0FFRztBQUNILCtDQUE4QjtBQUc5Qjs7R0FFRztBQUNILCtDQUE4QjtBQUc5Qjs7R0FFRztBQUNILCtDQUE4QjtBQUc5Qjs7R0FFRztBQUNILCtDQUE4QjtBQUc5Qjs7O0dBR0c7QUFDSCxpREFBZ0M7QUFHaEM7O0dBRUc7QUFDSCwrQ0FBOEI7QUFHOUI7O0dBRUc7QUFDSCwrQ0FBOEI7QUFHOUI7O0dBRUc7QUFDSCwrQ0FBOEIifQ==
4
+ var scalar_1 = require("./scalar");
5
+ Object.defineProperty(exports, "scalar", { enumerable: true, get: function () { return scalar_1.scalar; } });
6
+ var vec2_1 = require("./vec2");
7
+ Object.defineProperty(exports, "vec2", { enumerable: true, get: function () { return vec2_1.vec2; } });
8
+ var vec3_1 = require("./vec3");
9
+ Object.defineProperty(exports, "vec3", { enumerable: true, get: function () { return vec3_1.vec3; } });
10
+ var vec4_1 = require("./vec4");
11
+ Object.defineProperty(exports, "vec4", { enumerable: true, get: function () { return vec4_1.vec4; } });
12
+ var mat2_1 = require("./mat2");
13
+ Object.defineProperty(exports, "mat2", { enumerable: true, get: function () { return mat2_1.mat2; } });
14
+ var mat2d_1 = require("./mat2d");
15
+ Object.defineProperty(exports, "mat2d", { enumerable: true, get: function () { return mat2d_1.mat2d; } });
16
+ var mat3_1 = require("./mat3");
17
+ Object.defineProperty(exports, "mat3", { enumerable: true, get: function () { return mat3_1.mat3; } });
18
+ var mat4_1 = require("./mat4");
19
+ Object.defineProperty(exports, "mat4", { enumerable: true, get: function () { return mat4_1.mat4; } });
20
+ var quat_1 = require("./quat");
21
+ Object.defineProperty(exports, "quat", { enumerable: true, get: function () { return quat_1.quat; } });
22
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsbUNBQStCO0FBQXZCLGdHQUFBLE1BQU0sT0FBQTtBQUVkLCtCQUEyQjtBQUFuQiw0RkFBQSxJQUFJLE9BQUE7QUFFWiwrQkFBMkI7QUFBbkIsNEZBQUEsSUFBSSxPQUFBO0FBRVosK0JBQTJCO0FBQW5CLDRGQUFBLElBQUksT0FBQTtBQUVaLCtCQUEyQjtBQUFuQiw0RkFBQSxJQUFJLE9BQUE7QUFFWixpQ0FBNkI7QUFBckIsOEZBQUEsS0FBSyxPQUFBO0FBRWIsK0JBQTJCO0FBQW5CLDRGQUFBLElBQUksT0FBQTtBQUVaLCtCQUEyQjtBQUFuQiw0RkFBQSxJQUFJLE9BQUE7QUFFWiwrQkFBMkI7QUFBbkIsNEZBQUEsSUFBSSxPQUFBIn0=
package/lib/cjs/mat2.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Vec2 } from './vec2';
1
+ import { vec2 } from './vec2';
2
2
  /**
3
3
  * Represents 2D transformation exclude translation.
4
4
  * The format is column-major as in WebGL, so the matrix looks like this:
@@ -8,131 +8,136 @@ import { Vec2 } from './vec2';
8
8
  * ```
9
9
  * @category Types
10
10
  */
11
- export type Mat2 = readonly [m00: number, m01: number, m10: number, m11: number];
12
- /**
13
- * Mutable version of {@link Mat2}
14
- * @category Types
15
- */
16
- export type MutableMat2 = [m00: number, m01: number, m10: number, m11: number];
17
- /**
18
- * Creates a new matrix from given elements
19
- * @category Generators
20
- */
21
- export declare function of(m00: number, m01: number, m10: number, m11: number): Mat2;
22
- /**
23
- * Creates a mutable clone of given mat2
24
- * @category Generators
25
- */
26
- export declare function clone(a: Mat2): MutableMat2;
27
- /**
28
- * The identity matrix of mat2.
29
- * ```
30
- * [1, 0,
31
- * 0, 1]
32
- * ```
33
- * @category Constants
34
- */
35
- export declare const identity: Mat2;
36
- /**
37
- * The mat2d filled with zeros.
38
- * @category Constants
39
- */
40
- export declare const zero: Mat2;
41
- /**
42
- * Transpose the values of a mat2
43
- */
44
- export declare function transpose(a: Mat2): Mat2;
45
- /**
46
- * Inverts a mat2
47
- */
48
- export declare function invert(a: Mat2): Mat2 | null;
49
- /**
50
- * Calculates the adjugate of a mat2
51
- */
52
- export declare function adjoint(a: Mat2): Mat2;
53
- /**
54
- * Calculates the determinant of a mat2
55
- * @returns determinant of a
56
- */
57
- export declare function determinant(a: Mat2): number;
58
- /**
59
- * Multiplies given mat2's
60
- */
61
- export declare function multiply(...ms: Mat2[]): Mat2;
62
- /**
63
- * Rotates a mat2 by the given angle
64
- *
65
- * @param a the matrix to rotate
66
- * @param rad the angle to rotate the matrix by
67
- */
68
- export declare function rotate(a: Mat2, rad: number): Mat2;
69
- /**
70
- * Scales the mat2 by the dimensions in the given vec2
71
- **/
72
- export declare function scale(a: Mat2, b: Vec2 | number): Mat2;
73
- /**
74
- * Apply skew to the mat2d by the given angles
75
- * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew
76
- */
77
- export declare function skew(m: Mat2, rad: Vec2): Mat2;
78
- /**
79
- * Creates a matrix from a given angle
80
- * @category Generators
81
- */
82
- export declare function fromRotation(rad: number): Mat2;
83
- /**
84
- * Creates a matrix from a vector scaling
85
- * @category Generators
86
- */
87
- export declare function fromScaling(v: Vec2): Mat2;
88
- /**
89
- * Creates a matrix from a vector skew
90
- * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew
91
- * @category Generators
92
- */
93
- export declare function fromSkew(rad: Vec2): Mat2;
94
- /**
95
- * Returns Frobenius norm of a mat2
96
- */
97
- export declare function frob(a: Mat2): number;
98
- /**
99
- * Adds given mat2's
100
- */
101
- export declare function add(...ms: Mat2[]): Mat2;
102
- /**
103
- * Subtracts matrix b from matrix a
104
- */
105
- export declare function subtract(...ms: Mat2[]): Mat2;
106
- /**
107
- * Subtracts b from a
108
- */
109
- export declare function delta(a: Mat2, b: Mat2): Mat2;
110
- /**
111
- * Returns whether or not the matrices have exactly the same elements in the same position (when compared with `===`)
112
- */
113
- export declare function exactEquals(a: Mat2, b: Mat2): boolean;
114
- /**
115
- * Returns whether or not the matrices have approximately the same elements in the same position.
116
- */
117
- export declare function equals(a: Mat2, b: Mat2): boolean;
118
- /**
119
- * Alias for {@link identity}
120
- * @category Aliases
121
- */
122
- export declare const ident: Mat2;
123
- /**
124
- * Alias for {@link subtract}
125
- * @category Aliases
126
- */
127
- export declare const sub: typeof subtract;
128
- /**
129
- * Alias for {@link mat2.multiply}
130
- * @category Aliases
131
- */
132
- export declare const mul: typeof multiply;
133
- /**
134
- * Alias for {@link mat2.determinant}
135
- * @category Aliases
136
- */
137
- export declare const det: typeof determinant;
11
+ export type mat2 = readonly [m00: number, m01: number, m10: number, m11: number];
12
+ /**
13
+ * Functions for {@link mat2}, 2D transformation matrix exclude translation.
14
+ */
15
+ export declare namespace mat2 {
16
+ /**
17
+ * Mutable version of {@link mat2}
18
+ * @category Types
19
+ */
20
+ type Mutable = [m00: number, m01: number, m10: number, m11: number];
21
+ /**
22
+ * Creates a new matrix from given elements
23
+ * @category Generators
24
+ */
25
+ function of(m00: number, m01: number, m10: number, m11: number): mat2;
26
+ /**
27
+ * Creates a mutable clone of given mat2
28
+ * @category Generators
29
+ */
30
+ function clone(a: mat2): Mutable;
31
+ /**
32
+ * The identity matrix of mat2.
33
+ * ```
34
+ * [1, 0,
35
+ * 0, 1]
36
+ * ```
37
+ * @category Constants
38
+ */
39
+ const identity: mat2;
40
+ /**
41
+ * The mat2d filled with zeros.
42
+ * @category Constants
43
+ */
44
+ const zero: mat2;
45
+ /**
46
+ * Transpose the values of a mat2
47
+ */
48
+ function transpose(a: mat2): mat2;
49
+ /**
50
+ * Inverts a mat2
51
+ */
52
+ function invert(a: mat2): mat2 | null;
53
+ /**
54
+ * Calculates the adjugate of a mat2
55
+ */
56
+ function adjoint(a: mat2): mat2;
57
+ /**
58
+ * Calculates the determinant of a mat2
59
+ * @returns determinant of a
60
+ */
61
+ function determinant(a: mat2): number;
62
+ /**
63
+ * Multiplies given mat2's
64
+ */
65
+ function multiply(...ms: mat2[]): mat2;
66
+ /**
67
+ * Rotates a mat2 by the given angle
68
+ *
69
+ * @param a the matrix to rotate
70
+ * @param rad the angle to rotate the matrix by
71
+ */
72
+ function rotate(a: mat2, rad: number): mat2;
73
+ /**
74
+ * Scales the mat2 by the dimensions in the given vec2
75
+ **/
76
+ function scale(a: mat2, b: vec2 | number): mat2;
77
+ /**
78
+ * Apply skew to the mat2d by the given angles
79
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew
80
+ */
81
+ function skew(m: mat2, rad: vec2): mat2;
82
+ /**
83
+ * Creates a matrix from a given angle
84
+ * @category Generators
85
+ */
86
+ function fromRotation(rad: number): mat2;
87
+ /**
88
+ * Creates a matrix from a vector scaling
89
+ * @category Generators
90
+ */
91
+ function fromScaling(v: vec2): mat2;
92
+ /**
93
+ * Creates a matrix from a vector skew
94
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/skew
95
+ * @category Generators
96
+ */
97
+ function fromSkew(rad: vec2): mat2;
98
+ /**
99
+ * Returns Frobenius norm of a mat2
100
+ */
101
+ function frob(a: mat2): number;
102
+ /**
103
+ * Adds given mat2's
104
+ */
105
+ function add(...ms: mat2[]): mat2;
106
+ /**
107
+ * Subtracts matrix b from matrix a
108
+ */
109
+ function subtract(...ms: mat2[]): mat2;
110
+ /**
111
+ * Subtracts b from a
112
+ */
113
+ function delta(a: mat2, b: mat2): mat2;
114
+ /**
115
+ * Returns whether or not the matrices have exactly the same elements in the same position (when compared with `===`)
116
+ */
117
+ function exactEquals(a: mat2, b: mat2): boolean;
118
+ /**
119
+ * Returns whether or not the matrices have approximately the same elements in the same position.
120
+ */
121
+ function equals(a: mat2, b: mat2): boolean;
122
+ /**
123
+ * Alias for {@link identity}
124
+ * @category Aliases
125
+ */
126
+ const ident: mat2;
127
+ /**
128
+ * Alias for {@link subtract}
129
+ * @category Aliases
130
+ */
131
+ const sub: typeof subtract;
132
+ /**
133
+ * Alias for {@link mat2.multiply}
134
+ * @category Aliases
135
+ */
136
+ const mul: typeof multiply;
137
+ /**
138
+ * Alias for {@link mat2.determinant}
139
+ * @category Aliases
140
+ */
141
+ const det: typeof determinant;
142
+ }
138
143
  //# sourceMappingURL=mat2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mat2.d.ts","sourceRoot":"","sources":["../../src/mat2.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAA;AAE3B;;;;;;;;GAQG;AACH,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;AAEhF;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;AAE9E;;;GAGG;AACH,wBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAE3E;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,WAAW,CAE1C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,IAAkC,CAAA;AAEzD;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,IAAkC,CAAA;AAErD;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAMvC;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAgB3C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAIrC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,IAAI,UAElC;AAED;;GAEG;AACH,wBAAgB,QAAQ,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