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 62b3f5ed4a1..1e6e27fbf36 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 @@ -48,6 +48,12 @@ public class Vector { /** The z value */ public final double z; + /** + * Gram-Schmidt convergence envelope is a bit smaller than we really need because we don't want the math to fail afterwards in + * other places. + */ + private static final double MINIMUM_GRAM_SCHMIDT_ENVELOPE = MINIMUM_RESOLUTION * 0.5; + /** * Construct from (U.S.) x,y,z coordinates. *@param x is the x value. @@ -122,7 +128,7 @@ public class Vector { while (true) { final double currentDotProdA = AX * normalizeX + AY * normalizeY + AZ * normalizeZ; final double currentDotProdB = BX * normalizeX + BY * normalizeY + BZ * normalizeZ; - if (Math.abs(currentDotProdA) < MINIMUM_RESOLUTION && Math.abs(currentDotProdB) < MINIMUM_RESOLUTION) { + if (Math.abs(currentDotProdA) < MINIMUM_GRAM_SCHMIDT_ENVELOPE && Math.abs(currentDotProdB) < MINIMUM_GRAM_SCHMIDT_ENVELOPE) { break; } // Converge on the one that has largest dot product @@ -231,7 +237,7 @@ public class Vector { while (true) { final double currentDotProdA = A.x * normalizeX + A.y * normalizeY + A.z * normalizeZ; final double currentDotProdB = B.x * normalizeX + B.y * normalizeY + B.z * normalizeZ; - if (Math.abs(currentDotProdA) < MINIMUM_RESOLUTION && Math.abs(currentDotProdB) < MINIMUM_RESOLUTION) { + if (Math.abs(currentDotProdA) < MINIMUM_GRAM_SCHMIDT_ENVELOPE && Math.abs(currentDotProdB) < MINIMUM_GRAM_SCHMIDT_ENVELOPE) { break; } // Converge on the one that has largest dot product 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 d7828bddceb..af47e918df5 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 @@ -70,10 +70,11 @@ public class RandomPlaneTest extends RandomGeo3dShapeGenerator { if (plane == null) { fail(msg); } - assertTrue(plane.evaluate(check) + " " + msg, plane.isWithin(check)); - assertTrue(plane.evaluate(point1) + " " +msg, plane.isWithin(point3)); + // This is not expected + //assertTrue(plane.evaluate(check) + " " + msg, plane.isWithin(check)); + assertTrue(plane.evaluate(point1) + " " +msg, plane.isWithin(point1)); assertTrue(plane.evaluate(point2) + " " +msg, plane.isWithin(point2)); - assertTrue(plane.evaluate(point3) + " " +msg, plane.isWithin(point1)); + assertTrue(plane.evaluate(point3) + " " +msg, plane.isWithin(point3)); } }