@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.
- package/CHANGELOG.md +20 -16
- package/README.md +82 -2
- package/cjs/Line2D.js +33 -31
- package/cjs/MathConstants.js +4 -0
- package/cjs/Vec2.js +21 -0
- package/cjs/index.js +3 -1
- package/cjs/normalizeAngleDegrees.js +4 -0
- package/cjs/normalizeAngleRadians.js +7 -3
- package/docs/classes/BoundingBox.md +7 -7
- package/docs/classes/Line2D.md +80 -81
- package/docs/classes/Line3D.md +35 -35
- package/docs/classes/Polygon.md +38 -16
- package/docs/classes/Rectangle.md +18 -18
- package/docs/classes/Size2.md +3 -3
- package/docs/classes/Vec2.md +23 -6
- package/docs/classes/Vec3.md +12 -12
- package/docs/interfaces/Point2.md +30 -0
- package/docs/interfaces/Point3.md +41 -0
- package/docs/modules.md +68 -0
- package/esm/Line2D.js +33 -31
- package/esm/MathConstants.js +1 -0
- package/esm/Vec2.js +21 -0
- package/esm/index.js +1 -0
- package/esm/normalizeAngleDegrees.js +4 -0
- package/esm/normalizeAngleRadians.js +7 -3
- package/package.json +1 -1
- package/src/Line2D.ts +39 -34
- package/src/MathConstants.ts +1 -0
- package/src/Vec2.ts +26 -0
- package/src/index.ts +4 -1
- package/src/normalizeAngleDegrees.ts +4 -0
- package/src/normalizeAngleRadians.ts +11 -5
- package/types/Line2D.d.ts +10 -14
- package/types/MathConstants.d.ts +1 -0
- package/types/Vec2.d.ts +11 -0
- package/types/index.d.ts +3 -0
- package/types/normalizeAngleDegrees.d.ts +4 -0
- package/types/normalizeAngleRadians.d.ts +4 -0
- package/HowToRelease.txt +0 -13
|
@@ -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
|
-
|
|
3
|
-
|
|
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 +
|
|
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
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
|
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";
|
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.
|