Skip to content

Commit

Permalink
Fixed infinite line bug (#93)
Browse files Browse the repository at this point in the history
Issue: #91
  • Loading branch information
AdrianSolberg authored Aug 9, 2024
1 parent ec7cd97 commit ff6dc8f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Components/InfiniteLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ class InfiniteLine extends Line {
b[0] = (left - startVec3.x) / dir.x;
}
if (dir.y != 0) {
a[1] = (top - startVec3.y) / dir.y;
b[1] = (bottom - startVec3.y) / dir.y;
if ((startVec3.y > endVec3.y && startVec3.x < endVec3.x) || (startVec3.y < endVec3.y && startVec3.x > endVec3.x)) {
a[1] = (bottom - startVec3.y) / dir.y;
b[1] = (top - startVec3.y) / dir.y;
} else {
a[1] = (top - startVec3.y) / dir.y;
b[1] = (bottom - startVec3.y) / dir.y;
}
}

const closestA = a.reduce((prev, curr) =>
Expand Down

0 comments on commit ff6dc8f

Please sign in to comment.