@lakuna/umath 2.0.0 → 3.0.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 (88) hide show
  1. package/LICENSE +1 -1
  2. package/dist/algorithms/greatestCommonDivisor.d.ts.map +1 -1
  3. package/dist/algorithms/greatestCommonDivisor.js +14 -4
  4. package/dist/algorithms/greatestCommonDivisor.js.map +1 -1
  5. package/dist/index.d.ts +11 -11
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/linalg/DualQuaternion.d.ts +124 -124
  9. package/dist/linalg/DualQuaternion.d.ts.map +1 -1
  10. package/dist/linalg/DualQuaternion.js +173 -165
  11. package/dist/linalg/DualQuaternion.js.map +1 -1
  12. package/dist/linalg/Matrix.d.ts +24 -24
  13. package/dist/linalg/Matrix.d.ts.map +1 -1
  14. package/dist/linalg/Matrix2.d.ts +63 -63
  15. package/dist/linalg/Matrix2.d.ts.map +1 -1
  16. package/dist/linalg/Matrix2.js +92 -88
  17. package/dist/linalg/Matrix2.js.map +1 -1
  18. package/dist/linalg/Matrix3.d.ts +107 -107
  19. package/dist/linalg/Matrix3.d.ts.map +1 -1
  20. package/dist/linalg/Matrix3.js +147 -138
  21. package/dist/linalg/Matrix3.js.map +1 -1
  22. package/dist/linalg/Matrix4.d.ts +200 -201
  23. package/dist/linalg/Matrix4.d.ts.map +1 -1
  24. package/dist/linalg/Matrix4.js +272 -251
  25. package/dist/linalg/Matrix4.js.map +1 -1
  26. package/dist/linalg/Quaternion.d.ts +116 -116
  27. package/dist/linalg/Quaternion.d.ts.map +1 -1
  28. package/dist/linalg/Quaternion.js +175 -161
  29. package/dist/linalg/Quaternion.js.map +1 -1
  30. package/dist/linalg/SlowMatrix.d.ts +5 -5
  31. package/dist/linalg/SlowMatrix.d.ts.map +1 -1
  32. package/dist/linalg/SlowMatrix.js +12 -12
  33. package/dist/linalg/SlowMatrix.js.map +1 -1
  34. package/dist/linalg/SlowSquareMatrix.d.ts +6 -6
  35. package/dist/linalg/SlowSquareMatrix.d.ts.map +1 -1
  36. package/dist/linalg/SlowSquareMatrix.js +15 -15
  37. package/dist/linalg/SlowSquareMatrix.js.map +1 -1
  38. package/dist/linalg/SlowVector.d.ts +70 -70
  39. package/dist/linalg/SlowVector.d.ts.map +1 -1
  40. package/dist/linalg/SlowVector.js +153 -153
  41. package/dist/linalg/SlowVector.js.map +1 -1
  42. package/dist/linalg/SquareMatrix.d.ts +8 -8
  43. package/dist/linalg/SquareMatrix.d.ts.map +1 -1
  44. package/dist/linalg/Vector.d.ts +85 -84
  45. package/dist/linalg/Vector.d.ts.map +1 -1
  46. package/dist/linalg/Vector2.d.ts +104 -104
  47. package/dist/linalg/Vector2.d.ts.map +1 -1
  48. package/dist/linalg/Vector2.js +145 -143
  49. package/dist/linalg/Vector2.js.map +1 -1
  50. package/dist/linalg/Vector3.d.ts +130 -130
  51. package/dist/linalg/Vector3.d.ts.map +1 -1
  52. package/dist/linalg/Vector3.js +176 -173
  53. package/dist/linalg/Vector3.js.map +1 -1
  54. package/dist/linalg/Vector4.d.ts +101 -101
  55. package/dist/linalg/Vector4.d.ts.map +1 -1
  56. package/dist/linalg/Vector4.js +144 -140
  57. package/dist/linalg/Vector4.js.map +1 -1
  58. package/dist/types/AxisAngle.d.ts +2 -2
  59. package/dist/types/AxisAngle.d.ts.map +1 -1
  60. package/dist/types/FieldOfView.d.ts +2 -2
  61. package/dist/types/FieldOfView.d.ts.map +1 -1
  62. package/dist/utility/BigNumber.d.ts +21 -11
  63. package/dist/utility/BigNumber.d.ts.map +1 -1
  64. package/dist/utility/BigNumber.js +42 -31
  65. package/dist/utility/BigNumber.js.map +1 -1
  66. package/dist/utility/createAxisAngleLike.d.ts.map +1 -1
  67. package/dist/utility/createAxisAngleLike.js.map +1 -1
  68. package/package.json +11 -9
  69. package/src/algorithms/greatestCommonDivisor.ts +19 -7
  70. package/src/index.ts +17 -13
  71. package/src/linalg/DualQuaternion.ts +208 -193
  72. package/src/linalg/Matrix.ts +28 -28
  73. package/src/linalg/Matrix2.ts +117 -108
  74. package/src/linalg/Matrix3.ts +177 -158
  75. package/src/linalg/Matrix4.ts +386 -348
  76. package/src/linalg/Quaternion.ts +207 -189
  77. package/src/linalg/SlowMatrix.ts +19 -18
  78. package/src/linalg/SlowSquareMatrix.ts +19 -18
  79. package/src/linalg/SlowVector.ts +170 -169
  80. package/src/linalg/SquareMatrix.ts +9 -9
  81. package/src/linalg/Vector.ts +91 -89
  82. package/src/linalg/Vector2.ts +160 -155
  83. package/src/linalg/Vector3.ts +206 -199
  84. package/src/linalg/Vector4.ts +165 -156
  85. package/src/types/AxisAngle.ts +3 -3
  86. package/src/types/FieldOfView.ts +3 -3
  87. package/src/utility/BigNumber.ts +63 -41
  88. package/src/utility/createAxisAngleLike.ts +1 -0
@@ -1,8 +1,4 @@
1
- /**
2
- * An object that could be interpreted as a vector.
3
- * @public
4
- */
5
- export type VectorLike = Record<number, number>;
1
+ import type { Vector4Like } from "./Vector4.js";
6
2
 
7
3
  /**
8
4
  * A quantity with magnitude and direction.
@@ -11,179 +7,185 @@ export type VectorLike = Record<number, number>;
11
7
  */
12
8
  export default interface Vector extends VectorLike {
13
9
  /**
14
- * Determine whether this vector is roughly equivalent to another.
15
- * @param vector - The other vector.
16
- * @returns Whether the vectors are equivalent.
17
- */
18
- equals(vector: VectorLike): boolean;
19
-
20
- /**
21
- * Determine whether this vector is exactly equivalent to another.
10
+ * Add two vectors of the same size.
22
11
  * @param vector - The other vector.
23
- * @returns Whether the vectors are equivalent.
12
+ * @returns The sum of the vectors.
24
13
  */
25
- exactEquals(vector: VectorLike): boolean;
14
+ add: (vector: Vector4Like) => VectorLike;
26
15
 
27
16
  /**
28
- * Add two vectors of the same size.
29
- * @param vector - The other vector.
30
- * @returns The sum of the vectors.
17
+ * Round up the components of this vector.
18
+ * @returns The rounded vector.
31
19
  */
32
- add(vector: VectorLike): VectorLike;
20
+ ceil: () => VectorLike;
33
21
 
34
22
  /**
35
23
  * Create a copy of this vector.
36
24
  * @returns A copy of this vector.
37
25
  */
38
- clone(): VectorLike;
26
+ clone: () => VectorLike;
39
27
 
40
28
  /**
41
29
  * Copy the values of another vector into this one.
42
30
  * @param vector - The vector to copy.
43
31
  * @returns This vector.
44
32
  */
45
- copy(vector: VectorLike): this;
33
+ copy: (vector: Vector4Like) => this;
46
34
 
47
35
  /**
48
- * Multiply this vector by another.
36
+ * Calculate the Euclidean distance between this vector and another.
49
37
  * @param vector - The other vector.
50
- * @returns The product of the vectors.
38
+ * @returns The distance.
51
39
  */
52
- multiply(vector: VectorLike): VectorLike;
40
+ distance: (vector: Vector4Like) => number;
53
41
 
54
42
  /**
55
43
  * Divide this vector by another.
56
44
  * @param vector - The other vector.
57
45
  * @returns The quotient of the vectors.
58
46
  */
59
- divide(vector: VectorLike): VectorLike;
47
+ divide: (vector: Vector4Like) => VectorLike;
60
48
 
61
49
  /**
62
- * Subtract another vector from this one.
50
+ * Calculate the dot product of this and another vector.
63
51
  * @param vector - The other vector.
64
- * @returns The difference between the vectors.
52
+ * @returns The dot product.
53
+ * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
65
54
  */
66
- subtract(vector: VectorLike): VectorLike;
55
+ dot: (vector: Vector4Like) => number;
67
56
 
68
57
  /**
69
- * Round up the components of this vector.
70
- * @returns The rounded vector.
58
+ * Determine whether this vector is roughly equivalent to another.
59
+ * @param vector - The other vector.
60
+ * @returns Whether the vectors are equivalent.
61
+ */
62
+ equals: (vector: Vector4Like) => boolean;
63
+
64
+ /**
65
+ * Determine whether this vector is exactly equivalent to another.
66
+ * @param vector - The other vector.
67
+ * @returns Whether the vectors are equivalent.
71
68
  */
72
- ceil(): VectorLike;
69
+ exactEquals: (vector: Vector4Like) => boolean;
73
70
 
74
71
  /**
75
72
  * Round down the components of this vector.
76
73
  * @returns The rounded vector.
77
74
  */
78
- floor(): VectorLike;
75
+ floor: () => VectorLike;
79
76
 
80
77
  /**
81
- * Round the components of this vector.
82
- * @returns The rounded vector.
78
+ * Calculate the multiplicative inverse of the components of this vector.
79
+ * @returns The inverted vector.
83
80
  */
84
- round(): VectorLike;
81
+ invert: () => VectorLike;
85
82
 
86
83
  /**
87
- * Return the minimum of this and another vector.
84
+ * Perform a linear interpolation between this and another vector.
88
85
  * @param vector - The other vector.
89
- * @returns The minimum.
86
+ * @param t - The interpolation amount (in `[0,1]`).
87
+ * @returns The interpolated vector.
90
88
  */
91
- min(vector: VectorLike): VectorLike;
89
+ lerp: (vector: Vector4Like, t: number) => VectorLike;
90
+
91
+ /** Get the magnitude (length) of this vector. */
92
+ get magnitude(): number;
92
93
 
93
94
  /**
94
95
  * Return the maximum of this and another vector.
95
96
  * @param vector - The other vector.
96
97
  * @returns The maximum.
97
98
  */
98
- max(vector: VectorLike): VectorLike;
99
+ max: (vector: Vector4Like) => VectorLike;
99
100
 
100
101
  /**
101
- * Raise each component of this vector to the given power.
102
- * @param exponent - The exponent (power) to raise each component to.
103
- * @returns The power (result of the exponentiation).
102
+ * Return the minimum of this and another vector.
103
+ * @param vector - The other vector.
104
+ * @returns The minimum.
104
105
  */
105
- pow(exponent: number): VectorLike;
106
+ min: (vector: Vector4Like) => VectorLike;
106
107
 
107
108
  /**
108
- * Scale this vector by a scalar.
109
- * @param scalar - The scalar.
110
- * @returns The scaled vector.
109
+ * Multiply this vector by another.
110
+ * @param vector - The other vector.
111
+ * @returns The product of the vectors.
111
112
  */
112
- scale(scalar: number): VectorLike;
113
+ multiply: (vector: Vector4Like) => VectorLike;
113
114
 
114
115
  /**
115
- * Add another vector to this one after scaling the other by a scalar.
116
- * @param vector - The other vector.
117
- * @param scalar - The scalar.
118
- * @returns The sum.
116
+ * Negate this vector.
117
+ * @returns The negated vector.
119
118
  */
120
- scaleAndAdd(vector: VectorLike, scalar: number): VectorLike;
119
+ negate: () => VectorLike;
121
120
 
122
121
  /**
123
- * Calculate the Euclidean distance between this vector and another.
124
- * @param vector - The other vector.
125
- * @returns The distance.
122
+ * Normalize this vector.
123
+ * @returns The normalized vector.
124
+ * @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
126
125
  */
127
- distance(vector: VectorLike): number;
126
+ normalize: () => VectorLike;
128
127
 
129
128
  /**
130
- * Calculate the squared Euclidean distance between this vector and another.
131
- * @param vector - The other vector.
132
- * @returns The squared distance.
129
+ * Raise each component of this vector to the given power.
130
+ * @param exponent - The exponent (power) to raise each component to.
131
+ * @returns The power (result of the exponentiation).
133
132
  */
134
- squaredDistance(vector: VectorLike): number;
135
-
136
- /** Get the magnitude (length) of this vector. */
137
- get magnitude(): number;
138
-
139
- /** Get the squared magnitude (length) of this vector. */
140
- get squaredMagnitude(): number;
133
+ pow: (exponent: number) => VectorLike;
141
134
 
142
135
  /**
143
- * Negate this vector.
144
- * @returns The negated vector.
136
+ * Set this vector to a random value with the given magnitude.
137
+ * @param magnitude - The magnitude.
138
+ * @returns This vector.
145
139
  */
146
- negate(): VectorLike;
140
+ random: (magnitude: number) => this;
147
141
 
148
142
  /**
149
- * Calculate the multiplicative inverse of the components of this vector.
150
- * @returns The inverted vector.
143
+ * Round the components of this vector.
144
+ * @returns The rounded vector.
151
145
  */
152
- invert(): VectorLike;
146
+ round: () => VectorLike;
153
147
 
154
148
  /**
155
- * Normalize this vector.
156
- * @returns The normalized vector.
157
- * @see {@link https://en.wikipedia.org/wiki/Unit_vector | Unit vector}
149
+ * Scale this vector by a scalar.
150
+ * @param scalar - The scalar.
151
+ * @returns The scaled vector.
158
152
  */
159
- normalize(): VectorLike;
153
+ scale: (scalar: number) => VectorLike;
160
154
 
161
155
  /**
162
- * Calculate the dot product of this and another vector.
156
+ * Add another vector to this one after scaling the other by a scalar.
163
157
  * @param vector - The other vector.
164
- * @returns The dot product.
165
- * @see {@link https://en.wikipedia.org/wiki/Dot_product | Dot product}
158
+ * @param scalar - The scalar.
159
+ * @returns The sum.
166
160
  */
167
- dot(vector: VectorLike): number;
161
+ scaleAndAdd: (vector: Vector4Like, scalar: number) => VectorLike;
168
162
 
169
163
  /**
170
- * Perform a linear interpolation between this and another vector.
164
+ * Calculate the squared Euclidean distance between this vector and another.
171
165
  * @param vector - The other vector.
172
- * @param t - The interpolation amount (in `[0,1]`).
173
- * @returns The interpolated vector.
166
+ * @returns The squared distance.
174
167
  */
175
- lerp(vector: VectorLike, t: number): VectorLike;
168
+ squaredDistance: (vector: Vector4Like) => number;
169
+
170
+ /** Get the squared magnitude (length) of this vector. */
171
+ get squaredMagnitude(): number;
176
172
 
177
173
  /**
178
- * Set this vector to a random value with the given magnitude.
179
- * @param magnitude - The magnitude.
180
- * @returns This vector.
174
+ * Subtract another vector from this one.
175
+ * @param vector - The other vector.
176
+ * @returns The difference between the vectors.
181
177
  */
182
- random(magnitude: number): this;
178
+ subtract: (vector: Vector4Like) => VectorLike;
183
179
 
184
180
  /**
185
181
  * Set this to the zero vector.
186
182
  * @returns This vector.
187
183
  */
188
- zero(): this;
184
+ zero: () => this;
189
185
  }
186
+
187
+ /**
188
+ * An object that could be interpreted as a vector.
189
+ * @public
190
+ */
191
+ export type VectorLike = Record<number, number>;