Skip to content

Commit

Permalink
Fix convex hull algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanf committed Sep 27, 2024
1 parent d69a054 commit 04226a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/irregular/polygon_convex_hull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ int counter_clockwise(
const Point& point_2,
const Point& point_3)
{
int area = (point_2.x - point_1.x) * (point_3.y - point_1.y)
AreaDbl area = (point_2.x - point_1.x) * (point_3.y - point_1.y)
- (point_2.y - point_1.y) * (point_3.x - point_1.x);
if (area > 0) {
if (strictly_greater(area, 0)) {
return -1;
} else if (area < 0) {
} else if (strictly_lesser(area, 0)) {
return 1;
}
return 0;
Expand Down Expand Up @@ -83,7 +83,7 @@ Shape irregular::polygon_convex_hull(
convex_hull.push_back(points[1]);
//std::cout << "push " << points[1].to_string() << std::endl;

for (int pos = 2; pos < (ElementPos)points.size(); pos++) {
for (ElementPos pos = 2; pos < (ElementPos)points.size(); pos++) {
//std::cout << "pos " << pos << " / " << points.size() << std::endl;
//std::cout << "point " << points[pos].to_string() << std::endl;
Point top = convex_hull.back();
Expand Down

0 comments on commit 04226a3

Please sign in to comment.