From e9fe8dd4dd7420786fe496903aeb10db0f35c63f Mon Sep 17 00:00:00 2001 From: kevinshen1101 <40150857+kevinshen1101@users.noreply.github.com> Date: Fri, 3 Jun 2022 05:42:14 -0700 Subject: [PATCH] fix: Normalize coplanar dot product check in intersectLine (#49) --- src/Line3.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Line3.js b/src/Line3.js index 7ad9037..e7f3d1b 100644 --- a/src/Line3.js +++ b/src/Line3.js @@ -139,7 +139,9 @@ class Line3 { // Lines are not coplanar, stop here // Coplanar only if the vectors AB, u, v are linearly dependent, i.e AB . (u × v) = 0 const coplanarResult = dc.dot(daCrossDb); - if (!approximatelyEquals(coplanarResult, 0)) { + const normalizedCoplanarResult = + coplanarResult / (dc.lengthSq() * daCrossDb.lengthSq()); + if (!approximatelyEquals(normalizedCoplanarResult, 0)) { return; }