Proposal: Add Rotating Calipers Algorithm to Geometry Package #6673
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This proposal suggests adding the Rotating Calipers algorithm to the geometry package. The Rotating Calipers technique enables efficient geometric computations for convex polygons, specifically:
Diameter (largest distance between any two points of a convex polygon)
Width (smallest distance between two parallel lines enclosing the polygon)
Minimum-area bounding rectangle (rectangle of minimal area enclosing all points)
Purpose
Integrating Rotating Calipers will:
Enhance the geometry module with essential computational geometry algorithms.
Foster educational exploration of convex polygon properties.
Align with repository goals for well-documented, quality algorithms.
Implementation
A single, fully static and final class: RotatingCalipers.
All methods have complete JavaDoc documentation.
Comprehensive JUnit 5 unit tests covering both simple and complex cases.
Follows repository CheckStyle, formatting, and naming conventions (static/final, clear method names, etc.).
References
Shamos, M.I. (1978). Computational Geometry.
Wikipedia: Rotating Calipers.
Issue Details
Algorithm Name: Rotating Calipers
Problem Statement:
Given a set of points representing a convex polygon, efficiently compute its diameter, width, and minimum-area bounding rectangle using the rotating calipers technique.
Algorithm Description:
Compute the convex hull of the input points.
Apply rotating calipers to find the geometric property (diameter, width, rectangle).
Return results in proper data structures (e.g., PointPair, Rectangle).
Benefits
Educational: Learners can explore fundamental convex polygon properties interactively.
Repository Extension: Adds a robust, unit-tested geometric algorithm, maintaining educational and quality standards.
Implementation Details
All methods are static and class is final.
Full JavaDoc coverage.
All new code meets project CheckStyle, naming, and formatting rules.
All new tests use JUnit 5.
The PR changes only geometry package files; any unrelated CI failures (e.g., in BloomFilterTest) are not a result of this submission.
clang-format -i --style=file path/to/your/file.java