You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by kw...@apache.org on 2022/11/23 23:52:35 UTC

[lucene] 19/19: Fix problem in new Plane code

This is an automated email from the ASF dual-hosted git repository.

kwright pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git

commit e1b331acef7bd0f0a563dc7c9a84ecc398cc2613
Author: Karl David Wright <kw...@apache.org>
AuthorDate: Mon Nov 21 19:15:10 2022 -0500

    Fix problem in new Plane code
---
 .../src/java/org/apache/lucene/spatial3d/geom/Plane.java         | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
index 5d4ff0b56c4..5b09ee6e7d1 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Plane.java
@@ -232,7 +232,14 @@ public class Plane extends Vector {
         A1 = (-C1 * zDiff - yDiff) / xDiff;
       } else {
         // B1choice is C-A, so numerator is B-C
-        A1 = (B0 * xDiff - C0 * yDiff) / B1choice;
+        // A1 * xDiff + 1.0 * yDiff + C1 * zDiff = 0
+        // C1 * zDiff = -A1 * xDiff - 1.0 * yDiff
+        // C1 = (-A1 * xDiff - yDiff) / zDiff
+        // A0 * A1 + B0 * 1.0 + C0 * (-A1 * xDiff - yDiff) / zDiff = 0
+        // A1 * A0 * zDiff - A1 * C0 * xDiff + B0 * zDiff - C0 * yDiff = 0
+        // A1 * A0 * zDiff - A1 * C0 * xDiff = C0 * yDiff - B0 * zDiff
+        // A1 = (C0 * yDiff - B0 * zDiff) / (A0 * zDiff - C0 * xDiff)
+        A1 = (B0 * zDiff - C0 * yDiff) / B1choice;
         C1 = (-A1 * xDiff - yDiff) / zDiff;
       }
     } else if (Math.abs(C1choice) >= Math.abs(A1choice)