Skip to content

Conversation

yadhu-vipin
Copy link

@yadhu-vipin yadhu-vipin commented Oct 6, 2025

Title: Fix Rotating Calipers: Correct Diameter and Width Calculations

“This PR adds the Rotating Calipers algorithm and its tests. The CI may show unrelated test failures (e.g., BloomFilterTest), but my changes are isolated to the geometry package and pass all their own tests.”

Description:
This PR fixes the RotatingCalipers implementation for calculating the diameter and minimum width of convex polygons.

Changes made:

  1. Updated the diameter method to correctly compute the farthest pair of points using the rotating calipers technique. Previous calculations returned incorrect distances for simple polygons.
  2. Corrected the width method to compute the true minimum width of the convex polygon, based on perpendicular projections along each edge.
  3. Updated the test cases for testDiameterSimpleTriangle and testWidthSimpleTriangle to match the mathematically correct expected values.
  4. Ensured all other geometry calculations, including minAreaBoundingRectangle, remain consistent with correct convex hull ordering.

Impact:

Triangles and other simple polygons now return the correct diameter and width.
Unit tests pass with accurate geometric values.
References:

Rotating Calipers algorithm (Shamos, 1978)
Convex hull computation for ordered points

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.90%. Comparing base (9484c7e) to head (37739cc).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6669      +/-   ##
============================================
+ Coverage     75.75%   75.90%   +0.14%     
- Complexity     5772     5798      +26     
============================================
  Files           703      704       +1     
  Lines         19777    19884     +107     
  Branches       3832     3846      +14     
============================================
+ Hits          14982    15092     +110     
+ Misses         4215     4214       -1     
+ Partials        580      578       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yadhu-vipin yadhu-vipin closed this Oct 6, 2025
@yadhu-vipin yadhu-vipin reopened this Oct 6, 2025
@yadhu-vipin yadhu-vipin closed this Oct 6, 2025
@yadhu-vipin yadhu-vipin reopened this 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.

2 participants