Skip to content

Commit

Permalink
Improve performance of ConvexPolygon::overlap method.
Browse files Browse the repository at this point in the history
Calculation of Polygon overlaps with Circle and other Polygon gives
precise answer, these methods were made to return true/false. This also
helps with performance of overlap calculation for UnionRegions composed of polygons.
  • Loading branch information
andy-slac committed Dec 2, 2024
1 parent d6791ae commit 3da135b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ConvexPolygon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,22 +358,22 @@ Relationship ConvexPolygon::relate(Ellipse const & e) const {
}

TriState ConvexPolygon::overlaps(Box const &b) const {
// Due to approximations we cannot know exact answer.
// Relation with box uses approximations, we cannot know exact answer.
return _relationship_to_overlaps(relate(b));
}

TriState ConvexPolygon::overlaps(Circle const &c) const {
// Due to approximations we cannot know exact answer.
return _relationship_to_overlaps(relate(c));
// Circle relation is exact, not-disjoint means they overlap.
return TriState((relate(c) & DISJOINT) == 0);
}

TriState ConvexPolygon::overlaps(ConvexPolygon const &p) const {
// Due to approximations we cannot know exact answer.
return _relationship_to_overlaps(relate(p));
// Polygon relation is exact, not-disjoint means they overlap.
return TriState((relate(p) & DISJOINT) == 0);
}

TriState ConvexPolygon::overlaps(Ellipse const &e) const {
// Due to approximations we cannot know exact answer.
// Relation with ellipse uses approximations, we cannot know exact answer.
return _relationship_to_overlaps(relate(e));
}

Expand Down

0 comments on commit 3da135b

Please sign in to comment.