@immugio/three-math-extensions 0.2.5 → 0.2.7

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.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Normalizes an angle in degrees to the range [0, 360].
3
+ * @param angle in degrees
4
+ */
1
5
  export function normalizeAngleDegrees(angle: number): number {
2
6
  return ((angle % 360) + 360) % 360;
3
7
  }
@@ -1,9 +1,15 @@
1
+ import { TwoPI } from "./MathConstants";
2
+
3
+ /**
4
+ * Normalize an angle in radians to the range of 0 to 2π.
5
+ * @param angle in radians
6
+ */
1
7
  export function normalizeAngleRadians(angle: number): number {
2
- const twoPi = 2 * Math.PI;
3
- angle = angle % twoPi; // Use modulus to get the angle within the range of 0 to 2π
8
+ angle = angle % TwoPI; // Use modulus to get the angle within the range of 0 to 2π
9
+
4
10
  if (angle < 0) { // Add 2π if the angle is negative
5
- angle = angle + twoPi;
11
+ angle = angle + TwoPI;
6
12
  }
7
- return angle;
8
- }
9
13
 
14
+ return angle;
15
+ }
package/types/Line2D.d.ts CHANGED
@@ -144,20 +144,14 @@ export declare class Line2D {
144
144
  */
145
145
  chunk(maxSegmentLength: number): Line2D[];
146
146
  /**
147
- * Returns the closest point parameter on the **infinite** line to the given point.
147
+ * Returns the closest point on the line to the given point.
148
148
  * @param point
149
+ * @param clampToLine boolean (optional)
150
+ * @param target Vec2 (optional)
149
151
  */
150
- closestPointToPointParameterOnInfiniteLine(point: Vector2): number;
151
- /**
152
- * Returns the closest point on the **infinite** line to the given point.
153
- * @param point
154
- */
155
- closestPointOnInfiniteLine(point: Vector2): Vec2;
156
- /**
157
- * Returns the closest point on the line **section** to the given point.
158
- * @param point
159
- */
160
- closestPointOnLine(point: Vector2): Vec2;
152
+ closestPointToPoint(point: Vector2, clampToLine?: boolean, target?: Vec2): Vec2;
153
+ delta(target: Vec2): Vec2;
154
+ closestPointToPointParameter(point: any, clampToLine: any): number;
161
155
  /**
162
156
  * Returns the distance between the **infinite** line and the point.
163
157
  * @param point
@@ -208,11 +202,13 @@ export declare class Line2D {
208
202
  */
209
203
  intersect(other: Line2D): Vec2;
210
204
  /**
211
- * Check that the infinite lines intersect and that they are in the specified angle to each other
205
+ * Check that the line section intersect and that they are in the specified angle to each other
212
206
  * @param other Line
213
207
  * @param expectedAngleInRads number
208
+ * @param angleTolerance number
209
+ * @param distanceTolerance number
214
210
  */
215
- hasIntersectionWithAngle(other: Line2D, expectedAngleInRads: number): Vec2;
211
+ hasIntersectionWithAngle(other: Line2D, expectedAngleInRads: number, angleTolerance?: number, distanceTolerance?: number): Vec2;
216
212
  equals(other: Line2D): boolean;
217
213
  /**
218
214
  * Deep clone of this line
@@ -0,0 +1 @@
1
+ export declare const TwoPI: number;
package/types/Vec2.d.ts CHANGED
@@ -11,6 +11,11 @@ export declare class Vec2 extends Vector2 {
11
11
  * @returns A new Vec2 instance.
12
12
  */
13
13
  static fromPoint(point: Point2): Vec2;
14
+ /**
15
+ * Creates a new Vec2[] array from arguments of {x, y} objects.
16
+ * @param points - The ...{x, y} instances.
17
+ */
18
+ static fromPoints(...points: Point2[]): Vec2[];
14
19
  /**
15
20
  * Moves this Vec2 instance towards the target Vec2 by the given amount.
16
21
  * @param target - The target Vec2.
@@ -39,4 +44,10 @@ export declare class Vec2 extends Vector2 {
39
44
  * Returns the angle between this vector and positive x-axis, the return value is between 0 and 2PI
40
45
  */
41
46
  signedAngle(): number;
47
+ /**
48
+ * check if the angle between the two vectors is close enough to 0 or 180 degrees (same or opposite direction) within the given tolerance
49
+ * @param other Vector2
50
+ * @param toleranceRadians number angle tolerance in radians
51
+ */
52
+ parallelTo(other: Vector2, toleranceRadians?: number): boolean;
42
53
  }
package/types/index.d.ts CHANGED
@@ -8,3 +8,6 @@ export { BoundingBox } from "./BoundingBox";
8
8
  export { Rectangle } from "./Rectangle";
9
9
  export { normalizeAngleDegrees } from "./normalizeAngleDegrees";
10
10
  export { normalizeAngleRadians } from "./normalizeAngleRadians";
11
+ export { TwoPI } from "./MathConstants";
12
+ export { Point2 } from "./Point2";
13
+ export { Point3 } from "./Point3";
@@ -1 +1,5 @@
1
+ /**
2
+ * Normalizes an angle in degrees to the range [0, 360].
3
+ * @param angle in degrees
4
+ */
1
5
  export declare function normalizeAngleDegrees(angle: number): number;
@@ -1 +1,5 @@
1
+ /**
2
+ * Normalize an angle in radians to the range of 0 to 2π.
3
+ * @param angle in radians
4
+ */
1
5
  export declare function normalizeAngleRadians(angle: number): number;
package/HowToRelease.txt DELETED
@@ -1,13 +0,0 @@
1
- Update documentation:
2
- npx typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts --excludeExternals --excludeProtected --excludePrivate --githubPages false
3
-
4
- Before release
5
- - Ensure clean working directory
6
- - Ensure that the last release commit has a tag that matches the latest release number in the format "0.0.11". This step should have been completed in the previous release. It's only mentioned here in case it's for any reason missing.
7
- - Run "prerelease" script to verify that the code builds and the tests pass
8
-
9
- Release:
10
- - Bump up version in package.json e.g. "0.0.11" -> "0.0.12"
11
- - Run "version" script, it should add the new commits since the last release into `CHANGELOG.md`
12
- - Commit and push the changes in `package.json` and `CHANGELOG.md`, ideally, call the commit as the new release e.g. "`0.0.12`". This is not necessary but makes it easier to find
13
- - **Tag the commit** the new version number. In this example "`0.0.12`" and push. This is required for CI to build and publish to npm.