@lakuna/umath 0.0.3 → 0.0.4

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 (136) hide show
  1. package/README.md +33 -0
  2. package/dist/algorithms/combinations.d.ts +2 -0
  3. package/dist/algorithms/combinations.d.ts.map +1 -0
  4. package/dist/algorithms/combinations.js +5 -0
  5. package/dist/algorithms/combinations.js.map +1 -0
  6. package/dist/algorithms/degreesToRadians.d.ts +2 -0
  7. package/dist/algorithms/degreesToRadians.d.ts.map +1 -0
  8. package/dist/algorithms/degreesToRadians.js +4 -0
  9. package/dist/algorithms/degreesToRadians.js.map +1 -0
  10. package/dist/algorithms/factorial.d.ts +2 -0
  11. package/dist/algorithms/factorial.d.ts.map +1 -0
  12. package/dist/algorithms/factorial.js +4 -0
  13. package/dist/algorithms/factorial.js.map +1 -0
  14. package/dist/algorithms/fibonacci.d.ts +2 -0
  15. package/dist/algorithms/fibonacci.d.ts.map +1 -0
  16. package/dist/algorithms/fibonacci.js +9 -0
  17. package/dist/algorithms/fibonacci.js.map +1 -0
  18. package/dist/algorithms/isPrime.d.ts +2 -0
  19. package/dist/algorithms/isPrime.d.ts.map +1 -0
  20. package/dist/algorithms/isPrime.js +12 -0
  21. package/dist/algorithms/isPrime.js.map +1 -0
  22. package/dist/algorithms/permutations.d.ts +2 -0
  23. package/dist/algorithms/permutations.d.ts.map +1 -0
  24. package/dist/algorithms/permutations.js +5 -0
  25. package/dist/algorithms/permutations.js.map +1 -0
  26. package/dist/algorithms/primeFactorization.d.ts +2 -0
  27. package/dist/algorithms/primeFactorization.d.ts.map +1 -0
  28. package/dist/algorithms/primeFactorization.js +15 -0
  29. package/dist/algorithms/primeFactorization.js.map +1 -0
  30. package/dist/algorithms/radiansToDegrees.d.ts +2 -0
  31. package/dist/algorithms/radiansToDegrees.d.ts.map +1 -0
  32. package/dist/algorithms/radiansToDegrees.js +4 -0
  33. package/dist/algorithms/radiansToDegrees.js.map +1 -0
  34. package/dist/algorithms/summation.d.ts.map +1 -1
  35. package/dist/algorithms/summation.js.map +1 -1
  36. package/dist/index.d.ts +24 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +19 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/linear/DualQuaternion.d.ts +89 -0
  41. package/dist/linear/DualQuaternion.d.ts.map +1 -0
  42. package/dist/linear/DualQuaternion.js +530 -0
  43. package/dist/linear/DualQuaternion.js.map +1 -0
  44. package/dist/linear/Matrix.d.ts +18 -0
  45. package/dist/linear/Matrix.d.ts.map +1 -0
  46. package/dist/linear/Matrix.js +2 -0
  47. package/dist/linear/Matrix.js.map +1 -0
  48. package/dist/linear/Matrix2.d.ts +66 -0
  49. package/dist/linear/Matrix2.d.ts.map +1 -0
  50. package/dist/linear/Matrix2.js +240 -0
  51. package/dist/linear/Matrix2.js.map +1 -0
  52. package/dist/linear/Matrix3.d.ts +91 -0
  53. package/dist/linear/Matrix3.d.ts.map +1 -0
  54. package/dist/linear/Matrix3.js +533 -0
  55. package/dist/linear/Matrix3.js.map +1 -0
  56. package/dist/linear/Matrix4.d.ts +140 -0
  57. package/dist/linear/Matrix4.d.ts.map +1 -0
  58. package/dist/linear/Matrix4.js +1363 -0
  59. package/dist/linear/Matrix4.js.map +1 -0
  60. package/dist/linear/Quaternion.d.ts +80 -0
  61. package/dist/linear/Quaternion.d.ts.map +1 -0
  62. package/dist/linear/Quaternion.js +371 -0
  63. package/dist/linear/Quaternion.js.map +1 -0
  64. package/dist/linear/SquareMatrix.d.ts +7 -0
  65. package/dist/linear/SquareMatrix.d.ts.map +1 -0
  66. package/dist/linear/SquareMatrix.js +2 -0
  67. package/dist/linear/SquareMatrix.js.map +1 -0
  68. package/dist/linear/Vector.d.ts +30 -0
  69. package/dist/linear/Vector.d.ts.map +1 -0
  70. package/dist/linear/Vector.js +2 -0
  71. package/dist/linear/Vector.js.map +1 -0
  72. package/dist/linear/Vector2.d.ts +96 -0
  73. package/dist/linear/Vector2.d.ts.map +1 -0
  74. package/dist/linear/Vector2.js +293 -0
  75. package/dist/linear/Vector2.js.map +1 -0
  76. package/dist/linear/Vector3.d.ts +111 -0
  77. package/dist/linear/Vector3.d.ts.map +1 -0
  78. package/dist/linear/Vector3.js +466 -0
  79. package/dist/linear/Vector3.js.map +1 -0
  80. package/dist/linear/Vector4.d.ts +86 -0
  81. package/dist/linear/Vector4.d.ts.map +1 -0
  82. package/dist/linear/Vector4.js +348 -0
  83. package/dist/linear/Vector4.js.map +1 -0
  84. package/dist/types/AxisAngle.d.ts +6 -0
  85. package/dist/types/AxisAngle.d.ts.map +1 -0
  86. package/dist/types/AxisAngle.js +2 -0
  87. package/dist/types/AxisAngle.js.map +1 -0
  88. package/dist/types/FieldOfView.d.ts +7 -0
  89. package/dist/types/FieldOfView.d.ts.map +1 -0
  90. package/dist/types/FieldOfView.js +2 -0
  91. package/dist/types/FieldOfView.js.map +1 -0
  92. package/dist/utility/BigNumber.d.ts +1 -1
  93. package/dist/utility/BigNumber.d.ts.map +1 -1
  94. package/dist/utility/BigNumber.js +4 -1
  95. package/dist/utility/BigNumber.js.map +1 -1
  96. package/dist/utility/MagnitudeError.d.ts +4 -0
  97. package/dist/utility/MagnitudeError.d.ts.map +1 -0
  98. package/dist/utility/MagnitudeError.js +6 -0
  99. package/dist/utility/MagnitudeError.js.map +1 -0
  100. package/dist/utility/SingularMatrixError.d.ts +4 -0
  101. package/dist/utility/SingularMatrixError.d.ts.map +1 -0
  102. package/dist/utility/SingularMatrixError.js +6 -0
  103. package/dist/utility/SingularMatrixError.js.map +1 -0
  104. package/dist/utility/epsilon.d.ts +3 -0
  105. package/dist/utility/epsilon.d.ts.map +1 -0
  106. package/dist/utility/epsilon.js +2 -0
  107. package/dist/utility/epsilon.js.map +1 -0
  108. package/package.json +15 -7
  109. package/src/algorithms/combinations.ts +12 -0
  110. package/src/algorithms/degreesToRadians.ts +10 -0
  111. package/src/algorithms/factorial.ts +9 -0
  112. package/src/algorithms/fibonacci.ts +14 -0
  113. package/src/algorithms/greatestCommonDivisor.ts +2 -2
  114. package/src/algorithms/isPrime.ts +20 -0
  115. package/src/algorithms/permutations.ts +12 -0
  116. package/src/algorithms/primeFactorization.ts +21 -0
  117. package/src/algorithms/radiansToDegrees.ts +10 -0
  118. package/src/algorithms/summation.ts +4 -1
  119. package/src/index.ts +24 -0
  120. package/src/linear/DualQuaternion.ts +1213 -0
  121. package/src/linear/Matrix.ts +106 -0
  122. package/src/linear/Matrix2.ts +709 -0
  123. package/src/linear/Matrix3.ts +1194 -0
  124. package/src/linear/Matrix4.ts +2569 -0
  125. package/src/linear/Quaternion.ts +967 -0
  126. package/src/linear/SquareMatrix.ts +27 -0
  127. package/src/linear/Vector.ts +178 -0
  128. package/src/linear/Vector2.ts +979 -0
  129. package/src/linear/Vector3.ts +1320 -0
  130. package/src/linear/Vector4.ts +975 -0
  131. package/src/types/AxisAngle.ts +10 -0
  132. package/src/types/FieldOfView.ts +14 -0
  133. package/src/utility/BigNumber.ts +2 -1
  134. package/src/utility/MagnitudeError.ts +10 -0
  135. package/src/utility/SingularMatrixError.ts +13 -0
  136. package/src/utility/epsilon.ts +2 -0
@@ -0,0 +1,10 @@
1
+ import type { Vector3Like } from "@lakuna/umath/Vector3";
2
+
3
+ /** An axis and an angle to rotate around it. */
4
+ export default interface AxisAngle {
5
+ /** The axis to rotate around. */
6
+ axis: Vector3Like;
7
+
8
+ /** The angle to rotate around the axis by in radians. */
9
+ angle: number;
10
+ }
@@ -0,0 +1,14 @@
1
+ /** A field of view. */
2
+ export default interface FieldOfView {
3
+ /** The angle to the top of the field of view in degrees. */
4
+ upDegrees: number;
5
+
6
+ /** The angle to the bottom of the field of view in degrees. */
7
+ downDegrees: number;
8
+
9
+ /** The angle to the left edge of the field of view in degrees. */
10
+ leftDegrees: number;
11
+
12
+ /** The angle to the right edge of the field of view in degrees. */
13
+ rightDegrees: number;
14
+ }
@@ -1,4 +1,4 @@
1
- import { greatestCommonDivisor, type IntegerRepresentation } from "../index.js";
1
+ import { greatestCommonDivisor, type IntegerRepresentation } from "@lakuna/umath";
2
2
 
3
3
  /** A number with no maximum precise size. */
4
4
  export default class BigNumber {
@@ -18,6 +18,7 @@ export default class BigNumber {
18
18
  public constructor(dividend: IntegerRepresentation = 0, divisor: IntegerRepresentation = 1) {
19
19
  this.dividend = BigInt(dividend);
20
20
  this.divisor = BigInt(divisor);
21
+ if (!this.divisor) { throw new Error("Cannot divide by zero."); }
21
22
  this.simplify();
22
23
  }
23
24
 
@@ -0,0 +1,10 @@
1
+ /** An error resulting from using a vector that is too small. */
2
+ export default class MagnitudeError extends Error {
3
+ /**
4
+ * Creates an error resulting from using a vector that is too small.
5
+ * @param message The message of the error.
6
+ */
7
+ public constructor(message = "The vector is too small.") {
8
+ super(message);
9
+ }
10
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * An error resulting from trying to invert a singular matrix.
3
+ * @see [Invertible matrix](https://en.wikipedia.org/wiki/Invertible_matrix)
4
+ */
5
+ export default class SingularMatrixError extends Error {
6
+ /**
7
+ * Creates an error resulting from trying to invert a singular matrix.
8
+ * @param message The message of the error.
9
+ */
10
+ public constructor(message = "The matrix cannot be inverted.") {
11
+ super(message);
12
+ }
13
+ }
@@ -0,0 +1,2 @@
1
+ /** The largest difference between two numbers for them to be considered "roughly" equivalent. */
2
+ export default 0.000001;