mirror of https://github.com/apache/lucene.git
LUCENE-7408: Detect degenerate case in lagrangian bounds computation when it pops up.
This commit is contained in:
parent
8ad1a830fb
commit
d6bd6bbcbe
|
@ -1359,8 +1359,6 @@ public class Plane extends Vector {
|
||||||
// m * [- 2*A*ab^2*r + 2*A^2*ab^2*r*q + 2*B^2*ab^2*r*q + 2*C^2*c^2*r*q] +
|
// m * [- 2*A*ab^2*r + 2*A^2*ab^2*r*q + 2*B^2*ab^2*r*q + 2*C^2*c^2*r*q] +
|
||||||
// [ab^2 - 2*A*ab^2*q + A^2*ab^2*q^2 + B^2*ab^2*q^2 + C^2*c^2*q^2] = 0
|
// [ab^2 - 2*A*ab^2*q + A^2*ab^2*q^2 + B^2*ab^2*q^2 + C^2*c^2*q^2] = 0
|
||||||
|
|
||||||
//System.err.println(" computing X bound");
|
|
||||||
|
|
||||||
// Useful subexpressions for this bound
|
// Useful subexpressions for this bound
|
||||||
final double q = A*abSquared*k;
|
final double q = A*abSquared*k;
|
||||||
final double qSquared = q * q;
|
final double qSquared = q * q;
|
||||||
|
@ -1400,6 +1398,7 @@ public class Plane extends Vector {
|
||||||
assert Math.abs(a * m1 * m1 + b * m1 + c) < MINIMUM_RESOLUTION;
|
assert Math.abs(a * m1 * m1 + b * m1 + c) < MINIMUM_RESOLUTION;
|
||||||
final double m2 = (-b - sqrtResult) * commonDenom;
|
final double m2 = (-b - sqrtResult) * commonDenom;
|
||||||
assert Math.abs(a * m2 * m2 + b * m2 + c) < MINIMUM_RESOLUTION;
|
assert Math.abs(a * m2 * m2 + b * m2 + c) < MINIMUM_RESOLUTION;
|
||||||
|
if (Math.abs(m1) >= MINIMUM_RESOLUTION || Math.abs(m2) >= MINIMUM_RESOLUTION) {
|
||||||
final double l1 = r * m1 + q;
|
final double l1 = r * m1 + q;
|
||||||
final double l2 = r * m2 + q;
|
final double l2 = r * m2 + q;
|
||||||
// x = ((1 - l*A) * ab^2 ) / (2 * m)
|
// x = ((1 - l*A) * ab^2 ) / (2 * m)
|
||||||
|
@ -1418,11 +1417,14 @@ public class Plane extends Vector {
|
||||||
//assert evaluateIsZero(thePoint2): "Evaluation of point2: "+evaluate(thePoint2);
|
//assert evaluateIsZero(thePoint2): "Evaluation of point2: "+evaluate(thePoint2);
|
||||||
addPoint(boundsInfo, bounds, thePoint1);
|
addPoint(boundsInfo, bounds, thePoint1);
|
||||||
addPoint(boundsInfo, bounds, thePoint2);
|
addPoint(boundsInfo, bounds, thePoint2);
|
||||||
|
} else {
|
||||||
|
// This is a plane of the form A=n B=0 C=0. We can set a bound only by noting the D value.
|
||||||
|
boundsInfo.addXValue(-D/A);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// No solutions
|
// No solutions
|
||||||
}
|
}
|
||||||
} else if (Math.abs(b) > MINIMUM_RESOLUTION_SQUARED) {
|
} else if (Math.abs(b) > MINIMUM_RESOLUTION_SQUARED) {
|
||||||
//System.err.println("Not x quadratic");
|
|
||||||
// a = 0, so m = - c / b
|
// a = 0, so m = - c / b
|
||||||
final double m = -c / b;
|
final double m = -c / b;
|
||||||
final double l = r * m + q;
|
final double l = r * m + q;
|
||||||
|
@ -1569,6 +1571,7 @@ public class Plane extends Vector {
|
||||||
assert Math.abs(a * m1 * m1 + b * m1 + c) < MINIMUM_RESOLUTION;
|
assert Math.abs(a * m1 * m1 + b * m1 + c) < MINIMUM_RESOLUTION;
|
||||||
final double m2 = (-b - sqrtResult) * commonDenom;
|
final double m2 = (-b - sqrtResult) * commonDenom;
|
||||||
assert Math.abs(a * m2 * m2 + b * m2 + c) < MINIMUM_RESOLUTION;
|
assert Math.abs(a * m2 * m2 + b * m2 + c) < MINIMUM_RESOLUTION;
|
||||||
|
if (Math.abs(m1) >= MINIMUM_RESOLUTION || Math.abs(m2) >= MINIMUM_RESOLUTION) {
|
||||||
final double l1 = r * m1 + q;
|
final double l1 = r * m1 + q;
|
||||||
final double l2 = r * m2 + q;
|
final double l2 = r * m2 + q;
|
||||||
// x = (-l*A * ab^2 ) / (2 * m)
|
// x = (-l*A * ab^2 ) / (2 * m)
|
||||||
|
@ -1587,6 +1590,10 @@ public class Plane extends Vector {
|
||||||
//assert evaluateIsZero(thePoint2): "Evaluation of point2: "+evaluate(thePoint2);
|
//assert evaluateIsZero(thePoint2): "Evaluation of point2: "+evaluate(thePoint2);
|
||||||
addPoint(boundsInfo, bounds, thePoint1);
|
addPoint(boundsInfo, bounds, thePoint1);
|
||||||
addPoint(boundsInfo, bounds, thePoint2);
|
addPoint(boundsInfo, bounds, thePoint2);
|
||||||
|
} else {
|
||||||
|
// This is a plane of the form A=0 B=n C=0. We can set a bound only by noting the D value.
|
||||||
|
boundsInfo.addYValue(-D/B);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// No solutions
|
// No solutions
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,4 +405,18 @@ public class GeoCircleTest extends LuceneTestCase {
|
||||||
assertTrue(solid.isWithin(gp));
|
assertTrue(solid.isWithin(gp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoundsFailureCase2() {
|
||||||
|
final GeoCircle gc = GeoCircleFactory.makeGeoCircle(PlanetModel.WGS84, -2.7574435614238194E-13, 0.0, 1.5887859182593391);
|
||||||
|
final GeoPoint gp = new GeoPoint(PlanetModel.WGS84, 0.7980359504429014, 1.5964981068121482);
|
||||||
|
final XYZBounds bounds = new XYZBounds();
|
||||||
|
gc.getBounds(bounds);
|
||||||
|
System.out.println("Bounds = "+bounds);
|
||||||
|
System.out.println("Point = "+gp);
|
||||||
|
final XYZSolid solid = XYZSolidFactory.makeXYZSolid(PlanetModel.WGS84, bounds.getMinimumX(), bounds.getMaximumX(), bounds.getMinimumY(), bounds.getMaximumY(), bounds.getMinimumZ(), bounds.getMaximumZ());
|
||||||
|
|
||||||
|
assert gc.isWithin(gp)?solid.isWithin(gp):true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue