Skip to content

Commit

Permalink
bug fix for the corrected output of 2D Convex Hulls
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.pointclouds.org/pcl/trunk@8279 a9d63959-f2ad-4865-b262-bf0e56cfafb6
  • Loading branch information
aichim committed Dec 17, 2012
1 parent dd7a70c commit 6149729
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,30 @@ pcl::isXYPointIn2DXYPolygon (const PointT &point, const pcl::PointCloud<PointT>
xold = xnew;
yold = ynew;
}

// And a last check for the polygon line formed by the last and the first points
double xnew = polygon.points[0].x;
double ynew = polygon.points[0].y;
if (xnew > xold)
{
x1 = xold;
x2 = xnew;
y1 = yold;
y2 = ynew;
}
else
{
x1 = xnew;
x2 = xold;
y1 = ynew;
y2 = yold;
}

if ( (xnew < point.x) == (point.x <= xold) && (point.y - y1) * (x2 - x1) < (y2 - y1) * (point.x - x1) )
{
in_poly = !in_poly;
}

return (in_poly);
}

Expand Down

0 comments on commit 6149729

Please sign in to comment.