Return CELL_CROSSES_QUERY when point inside the triangle (#1259)

This commit is contained in:
Ignacio Vera 2020-02-14 17:06:33 +01:00 committed by GitHub
parent 2b4fad53e5
commit ebec456602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -72,7 +72,7 @@ final class Point2D implements Component2D {
return contains(ax, ay) ? PointValues.Relation.CELL_INSIDE_QUERY : PointValues.Relation.CELL_OUTSIDE_QUERY; return contains(ax, ay) ? PointValues.Relation.CELL_INSIDE_QUERY : PointValues.Relation.CELL_OUTSIDE_QUERY;
} }
if (Component2D.pointInTriangle(minX, maxX, minY, maxY, x, y, ax, ay, bx, by, cx, cy)) { if (Component2D.pointInTriangle(minX, maxX, minY, maxY, x, y, ax, ay, bx, by, cx, cy)) {
return PointValues.Relation.CELL_INSIDE_QUERY; return PointValues.Relation.CELL_CROSSES_QUERY;
} }
return PointValues.Relation.CELL_OUTSIDE_QUERY; return PointValues.Relation.CELL_OUTSIDE_QUERY;
} }

View File

@ -43,7 +43,7 @@ public class TestPoint2D extends LuceneTestCase {
double by = 0; double by = 0;
double cx = 0; double cx = 0;
double cy = 1; double cy = 1;
assertEquals(Relation.CELL_INSIDE_QUERY, point2D.relateTriangle(ax, ay, bx, by , cx, cy)); assertEquals(Relation.CELL_CROSSES_QUERY, point2D.relateTriangle(ax, ay, bx, by , cx, cy));
assertEquals(Component2D.WithinRelation.CANDIDATE, assertEquals(Component2D.WithinRelation.CANDIDATE,
point2D.withinTriangle(ax, ay, random().nextBoolean(), bx, by, random().nextBoolean(), cx, cy, random().nextBoolean())); point2D.withinTriangle(ax, ay, random().nextBoolean(), bx, by, random().nextBoolean(), cx, cy, random().nextBoolean()));
} }