Skip to content

Commit eca891e

Browse files
committed
fix intersects() for convex polygons
Signed-off-by: mitukou1109 <mitukou1109@gmail.com>
1 parent f6db68d commit eca891e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

common/autoware_universe_utils/src/geometry/alt_geometry.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,10 @@ bool intersects(
482482

483483
bool intersects(const alt::ConvexPolygon2d & poly1, const alt::ConvexPolygon2d & poly2)
484484
{
485-
if (equals(poly1, poly2)) {
486-
return true;
485+
for (const auto & vertex : poly1.vertices()) {
486+
if (touches(vertex, poly2)) {
487+
return true;
488+
}
487489
}
488490

489491
// GJK algorithm
@@ -633,7 +635,7 @@ bool touches(const alt::Point2d & point, const alt::PointList2d & line)
633635
}
634636

635637
for (auto it = line.cbegin(); it != std::prev(line.cend()); ++it) {
636-
// check if the point is on each edge of the polygon
638+
// check if the point is on each segment
637639
if (touches(point, *it, *std::next(it))) {
638640
return true;
639641
}

0 commit comments

Comments
 (0)