From 0593eca73dce844c31492ebab0bc27fc2a772ca6 Mon Sep 17 00:00:00 2001 From: Karl David Wright Date: Mon, 21 Nov 2022 19:15:10 -0500 Subject: [PATCH] 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 e13fa2587fd..79719ba4119 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)