@immugio/three-math-extensions 0.2.8 → 0.2.9
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 +10 -2
- package/cjs/Line2D.js +11 -2
- package/esm/Line2D.js +11 -2
- package/package.json +1 -1
- package/src/Line2D.ts +12 -2
- package/types/Line2D.d.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
9
9
|
|
|
10
|
-
## [0.2.
|
|
10
|
+
## [0.2.9](https://github.com/Immugio/three-math-extensions/compare/16.15.10...0.2.9)
|
|
11
11
|
|
|
12
12
|
### Commits
|
|
13
13
|
|
|
@@ -19,6 +19,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
19
19
|
- Add Vec2.signedAngle [`863c8f2`](https://github.com/Immugio/three-math-extensions/commit/863c8f27f11288cbda535e21bb688206259269ed)
|
|
20
20
|
- Add Vec2.fromPoints to accept multiple points [`a261402`](https://github.com/Immugio/three-math-extensions/commit/a2614027cf5fb8263189b48f7e0bb9a23a552c15)
|
|
21
21
|
- Add Vec2.parallelTo [`989874d`](https://github.com/Immugio/three-math-extensions/commit/989874dcfe122d3ee84d8d56d79cb88e4e441736)
|
|
22
|
+
- Line2D.intersect - enable line segments intersection only [`1f1470e`](https://github.com/Immugio/three-math-extensions/commit/1f1470e1cf00118e643f5c44a135e0baf6b76d41)
|
|
22
23
|
- Polygon from bounding size [`eae6701`](https://github.com/Immugio/three-math-extensions/commit/eae67012f57f426f8b5259b765000447ce06d608)
|
|
23
24
|
- Line2D and Line3D to return this instead of specific type [`761ef6a`](https://github.com/Immugio/three-math-extensions/commit/761ef6a9d8cc4e35120b666576794e521aa3b991)
|
|
24
25
|
- Line2D.in3DSpace added [`a6ce0ec`](https://github.com/Immugio/three-math-extensions/commit/a6ce0ecb67f5c7b2a75fcc283c28af626153a4af)
|
|
@@ -29,7 +30,14 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
29
30
|
- Vec2.fromPoint and Vec3.fromPoint should accept null [`4b871af`](https://github.com/Immugio/three-math-extensions/commit/4b871af297bdcbe8584f1e2b99d602247b77687c)
|
|
30
31
|
- Excluded files from build [`ec70614`](https://github.com/Immugio/three-math-extensions/commit/ec70614bc7df7a98f854c7a6693365118e04faf7)
|
|
31
32
|
|
|
32
|
-
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.
|
|
33
|
+
## [16.15.10](https://github.com/Immugio/three-math-extensions/compare/0.2.8...16.15.10) - 2023-01-02
|
|
34
|
+
|
|
35
|
+
## [0.2.8](https://github.com/Immugio/three-math-extensions/compare/0.2.7...0.2.8) - 2023-05-19
|
|
36
|
+
|
|
37
|
+
### Commits
|
|
38
|
+
|
|
39
|
+
- Line2D.in3DSpace added [`a6ce0ec`](https://github.com/Immugio/three-math-extensions/commit/a6ce0ecb67f5c7b2a75fcc283c28af626153a4af)
|
|
40
|
+
- Update release instructions [`5b41a2e`](https://github.com/Immugio/three-math-extensions/commit/5b41a2ed7e15450dbb6088a7f7ed0031a013badc)
|
|
33
41
|
|
|
34
42
|
## [0.2.7](https://github.com/Immugio/three-math-extensions/compare/0.2.6...0.2.7) - 2023-04-26
|
|
35
43
|
|
package/cjs/Line2D.js
CHANGED
|
@@ -514,9 +514,11 @@ class Line2D {
|
|
|
514
514
|
return this;
|
|
515
515
|
}
|
|
516
516
|
/**
|
|
517
|
-
* Returns the intersection point of two lines.
|
|
517
|
+
* Returns the intersection point of two lines.
|
|
518
|
+
* @param other
|
|
519
|
+
* @param lineSegmentOnly If true, only return the intersection if it is within the line segments. Otherwise, return the intersection if the lines intersect anywhere.
|
|
518
520
|
*/
|
|
519
|
-
intersect(other) {
|
|
521
|
+
intersect(other, lineSegmentOnly) {
|
|
520
522
|
// Check if none of the lines are of length 0
|
|
521
523
|
if ((this.start.x === this.end.x && this.start.y === this.end.y) || (other.start.x === other.end.x && other.start.y === other.end.y)) {
|
|
522
524
|
return null;
|
|
@@ -527,6 +529,13 @@ class Line2D {
|
|
|
527
529
|
return null;
|
|
528
530
|
}
|
|
529
531
|
const ua = ((other.end.x - other.start.x) * (this.start.y - other.start.y) - (other.end.y - other.start.y) * (this.start.x - other.start.x)) / denominator;
|
|
532
|
+
// Check if the intersection point is within the bounds of the line segments if required
|
|
533
|
+
if (lineSegmentOnly) {
|
|
534
|
+
const ub = ((this.end.x - this.start.x) * (this.start.y - other.start.y) - (this.end.y - this.start.y) * (this.start.x - other.start.x)) / denominator;
|
|
535
|
+
if (ua < 0 || ua > 1 || ub < 0 || ub > 1) {
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
530
539
|
// Return an object with the x and y coordinates of the intersection
|
|
531
540
|
const x = this.start.x + ua * (this.end.x - this.start.x);
|
|
532
541
|
const y = this.start.y + ua * (this.end.y - this.start.y);
|
package/esm/Line2D.js
CHANGED
|
@@ -511,9 +511,11 @@ export class Line2D {
|
|
|
511
511
|
return this;
|
|
512
512
|
}
|
|
513
513
|
/**
|
|
514
|
-
* Returns the intersection point of two lines.
|
|
514
|
+
* Returns the intersection point of two lines.
|
|
515
|
+
* @param other
|
|
516
|
+
* @param lineSegmentOnly If true, only return the intersection if it is within the line segments. Otherwise, return the intersection if the lines intersect anywhere.
|
|
515
517
|
*/
|
|
516
|
-
intersect(other) {
|
|
518
|
+
intersect(other, lineSegmentOnly) {
|
|
517
519
|
// Check if none of the lines are of length 0
|
|
518
520
|
if ((this.start.x === this.end.x && this.start.y === this.end.y) || (other.start.x === other.end.x && other.start.y === other.end.y)) {
|
|
519
521
|
return null;
|
|
@@ -524,6 +526,13 @@ export class Line2D {
|
|
|
524
526
|
return null;
|
|
525
527
|
}
|
|
526
528
|
const ua = ((other.end.x - other.start.x) * (this.start.y - other.start.y) - (other.end.y - other.start.y) * (this.start.x - other.start.x)) / denominator;
|
|
529
|
+
// Check if the intersection point is within the bounds of the line segments if required
|
|
530
|
+
if (lineSegmentOnly) {
|
|
531
|
+
const ub = ((this.end.x - this.start.x) * (this.start.y - other.start.y) - (this.end.y - this.start.y) * (this.start.x - other.start.x)) / denominator;
|
|
532
|
+
if (ua < 0 || ua > 1 || ub < 0 || ub > 1) {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
527
536
|
// Return an object with the x and y coordinates of the intersection
|
|
528
537
|
const x = this.start.x + ua * (this.end.x - this.start.x);
|
|
529
538
|
const y = this.start.y + ua * (this.end.y - this.start.y);
|
package/package.json
CHANGED
package/src/Line2D.ts
CHANGED
|
@@ -600,9 +600,11 @@ export class Line2D {
|
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
/**
|
|
603
|
-
* Returns the intersection point of two lines.
|
|
603
|
+
* Returns the intersection point of two lines.
|
|
604
|
+
* @param other
|
|
605
|
+
* @param lineSegmentOnly If true, only return the intersection if it is within the line segments. Otherwise, return the intersection if the lines intersect anywhere.
|
|
604
606
|
*/
|
|
605
|
-
public intersect(other: Line2D): Vec2 {
|
|
607
|
+
public intersect(other: Line2D, lineSegmentOnly?: boolean): Vec2 {
|
|
606
608
|
// Check if none of the lines are of length 0
|
|
607
609
|
if ((this.start.x === this.end.x && this.start.y === this.end.y) || (other.start.x === other.end.x && other.start.y === other.end.y)) {
|
|
608
610
|
return null;
|
|
@@ -617,6 +619,14 @@ export class Line2D {
|
|
|
617
619
|
|
|
618
620
|
const ua = ((other.end.x - other.start.x) * (this.start.y - other.start.y) - (other.end.y - other.start.y) * (this.start.x - other.start.x)) / denominator;
|
|
619
621
|
|
|
622
|
+
// Check if the intersection point is within the bounds of the line segments if required
|
|
623
|
+
if (lineSegmentOnly) {
|
|
624
|
+
const ub = ((this.end.x - this.start.x) * (this.start.y - other.start.y) - (this.end.y - this.start.y) * (this.start.x - other.start.x)) / denominator;
|
|
625
|
+
if (ua < 0 || ua > 1 || ub < 0 || ub > 1) {
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
620
630
|
// Return an object with the x and y coordinates of the intersection
|
|
621
631
|
const x = this.start.x + ua * (this.end.x - this.start.x);
|
|
622
632
|
const y = this.start.y + ua * (this.end.y - this.start.y);
|
package/types/Line2D.d.ts
CHANGED
|
@@ -199,9 +199,11 @@ export declare class Line2D {
|
|
|
199
199
|
*/
|
|
200
200
|
extendToOrTrimAtIntersection(other: Line2D, maxDistanceToIntersection?: number): this;
|
|
201
201
|
/**
|
|
202
|
-
* Returns the intersection point of two lines.
|
|
202
|
+
* Returns the intersection point of two lines.
|
|
203
|
+
* @param other
|
|
204
|
+
* @param lineSegmentOnly If true, only return the intersection if it is within the line segments. Otherwise, return the intersection if the lines intersect anywhere.
|
|
203
205
|
*/
|
|
204
|
-
intersect(other: Line2D): Vec2;
|
|
206
|
+
intersect(other: Line2D, lineSegmentOnly?: boolean): Vec2;
|
|
205
207
|
/**
|
|
206
208
|
* Check that the line section intersect and that they are in the specified angle to each other
|
|
207
209
|
* @param other Line
|