feat(geometry): add line segment intersection utility#7376
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7376 +/- ##
=========================================
Coverage 79.50% 79.50%
- Complexity 7142 7161 +19
=========================================
Files 796 797 +1
Lines 23368 23409 +41
Branches 4596 4603 +7
=========================================
+ Hits 18578 18612 +34
- Misses 4050 4053 +3
- Partials 740 744 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR primarily introduces a new geometry utility for 2D line segment intersection checks and (when uniquely defined) intersection point calculation, along with dedicated unit tests. It also adds additional null-input tests for IterativeBinarySearch, which appears unrelated to the PR’s stated geometry scope.
Changes:
- Added
LineIntersectionutility withintersects(...)andintersectionPoint(...). - Added
LineIntersectionTestcovering several intersection scenarios. - Added
IterativeBinarySearchTestcoverage for null array / null key behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/main/java/com/thealgorithms/geometry/LineIntersection.java | New segment intersection utility and intersection-point computation. |
| src/test/java/com/thealgorithms/geometry/LineIntersectionTest.java | New unit tests for the new geometry utility. |
| src/test/java/com/thealgorithms/searches/IterativeBinarySearchTest.java | Added tests for null input handling in iterative binary search. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/test/java/com/thealgorithms/searches/IterativeBinarySearchTest.java
Outdated
Show resolved
Hide resolved
7efe55e to
f01ad41
Compare
Description
Add a dedicated geometry utility for line segment intersection.
Fixes #6856
Changes
LineIntersectionutility with:intersects(...)for segment intersection checks (including endpoint touching / collinear checks)intersectionPoint(...)to compute a unique geometric intersection point for non-parallel segmentsLineIntersectionTestcoverage for:Validation
mvn -q -Dtest=LineIntersectionTest test