Skip to content

Polygon Minimal Bounding Circle #110

Merged
SoloByte merged 2 commits intomainfrom
better-polygon-bounding-circle-algorithm
Nov 6, 2025
Merged

Polygon Minimal Bounding Circle #110
SoloByte merged 2 commits intomainfrom
better-polygon-bounding-circle-algorithm

Conversation

@SoloByte
Copy link
Copy Markdown
Collaborator

@SoloByte SoloByte commented Nov 5, 2025

I have added a new implementation of the GetBoundingCircle() function to caluculate the correct minimal-bounding-circle of a polygon. The old function is still available, because it is slightly faster and a lot simpler but it does not produce minimal bounding circles (resulting circles always contain all polygon points but might be bigger than necessary).

@SoloByte SoloByte added this to the 5.0 milestone Nov 5, 2025
@SoloByte SoloByte self-assigned this Nov 5, 2025
@SoloByte SoloByte added improvement Improvement of existing code. performance refactor labels Nov 5, 2025
@SoloByte SoloByte requested a review from Copilot November 5, 2025 15:25
Copy link
Copy Markdown
Contributor

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 refactors the bounding circle computation for polygons, introducing Welzl's algorithm for computing minimal enclosing circles and improving the bounding box calculation performance.

  • Renames the original GetBoundingCircle to GetBoundingCircleSimple and marks it as non-minimal
  • Implements Welzl's algorithm for computing the true minimal bounding circle via the new GetBoundingCircle method
  • Adds a Circumcenter property that returns the center of the minimal bounding circle
  • Optimizes GetBoundingBox to avoid unnecessary object allocations and iterations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SoloByte SoloByte merged commit 9ab52ec into main Nov 6, 2025
7 checks passed
@SoloByte SoloByte deleted the better-polygon-bounding-circle-algorithm branch November 6, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement of existing code. performance refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants