Skip to content

Apache Lucene open-source search software

LUCENE-8171: Check only for exactly zero magnitude vector, and otherwise let the iterative code try to converge.

Karl Wrightdd08400a3db1
diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java
index 5209df8fb96..62b3f5ed4a1 100755
--- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java
+++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/Vector.java
@@ -106,10 +106,9 @@ public class Vector {
final double thisZ = AX * BY - AY * BX;
final double magnitude = magnitude(thisX, thisY, thisZ);
- if (magnitude < MINIMUM_RESOLUTION) {
+ if (magnitude == 0.0) {
throw new IllegalArgumentException("Degenerate/parallel vector constructed");
}
-
final double inverseMagnitude = 1.0/magnitude;
double normalizeX = thisX * inverseMagnitude;
@@ -215,7 +214,7 @@ public class Vector {
final double thisZ = A.x * B.y - A.y * B.x;
final double magnitude = magnitude(thisX, thisY, thisZ);
- if (magnitude < MINIMUM_RESOLUTION) {
+ if (magnitude == 0.0) {
return true;
}
diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java
index 8c94c9c5154..d7828bddceb 100644
--- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java
+++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/geom/RandomPlaneTest.java
@@ -52,7 +52,6 @@ public class RandomPlaneTest extends RandomGeo3dShapeGenerator {
}
}
- @Ignore
@Test
@Repeat(iterations = 10)
public void testPlaneThreePointsAccuracy() {