Skip to content

Conversation

yadhu-vipin
Copy link

This PR fixes an issue in the ConvexHull class where the recursive method returned hull points in an unordered fashion due to the use of a HashSet. This caused algorithms that rely on vertex order, such as Rotating Calipers, to produce incorrect results (e.g., incorrect minimum bounding rectangle areas).

The fix preserves the counter-clockwise (CCW) order of the hull points while maintaining all points that lie on the convex polygon. This ensures compatibility with downstream geometric algorithms.

Changes:

  • Replaced HashSet with LinkedHashSet or List + sorting to preserve order.
  • Ensured deterministic CCW ordering starting from the bottom-most, left-most point.
  • Updated test expectations to match the ordered output.

Impact:

  • Algorithms like Rotating Calipers now compute correct values.
  • Maintains correctness for all convex hull computations.

@yadhu-vipin yadhu-vipin closed this by deleting the head repository Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant