Skip to content

feat(geometry): add line segment intersection utility#7376

Merged
DenizAltunkapan merged 4 commits intoTheAlgorithms:masterfrom
nickzerjeski:feat-geometry-line-intersection-6856
Apr 13, 2026
Merged

feat(geometry): add line segment intersection utility#7376
DenizAltunkapan merged 4 commits intoTheAlgorithms:masterfrom
nickzerjeski:feat-geometry-line-intersection-6856

Conversation

@nickzerjeski
Copy link
Copy Markdown
Contributor

Description

Add a dedicated geometry utility for line segment intersection.

Fixes #6856

Changes

  • Added LineIntersection utility with:
    • intersects(...) for segment intersection checks (including endpoint touching / collinear checks)
    • intersectionPoint(...) to compute a unique geometric intersection point for non-parallel segments
  • Added LineIntersectionTest coverage for:
    • crossing segments
    • parallel non-intersecting segments
    • endpoint touching segments
    • collinear overlap (non-unique intersection point)

Validation

  • mvn -q -Dtest=LineIntersectionTest test

Copilot AI review requested due to automatic review settings April 13, 2026 08:40
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 73.17073% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.50%. Comparing base (1edf319) to head (481c2d0).

Files with missing lines Patch % Lines
...a/com/thealgorithms/geometry/LineIntersection.java 73.17% 4 Missing and 7 partials ⚠️
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.
📢 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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LineIntersection utility with intersects(...) and intersectionPoint(...).
  • Added LineIntersectionTest covering several intersection scenarios.
  • Added IterativeBinarySearchTest coverage 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.

@nickzerjeski nickzerjeski force-pushed the feat-geometry-line-intersection-6856 branch from 7efe55e to f01ad41 Compare April 13, 2026 09:08
@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) April 13, 2026 11:01
@DenizAltunkapan DenizAltunkapan merged commit 79bc620 into TheAlgorithms:master Apr 13, 2026
7 checks passed
@nickzerjeski nickzerjeski deleted the feat-geometry-line-intersection-6856 branch April 13, 2026 16:07
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.

[FEATURE REQUEST] Add LineIntersection in geometry #hacktoberfest

4 participants