-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: rewrite ClosestLine and PolygonPolygonClosestLine logic for impr…
…oved accuracy on sloped polygons (#3124) Improves accuracy of PolygonPolygonClosestLine and ClosestLine functions. Big disclaimer, I heavily relied on ChatGPT for the math logic here... extra eyes greatly appreciated. I myself plan to do a deeper review on the math here before merging. Before: https://github.com/user-attachments/assets/a0d9d5d5-76e9-4e05-8459-15b6a48b0dcb After: https://github.com/user-attachments/assets/85d4410b-2bf2-4f51-90e2-4ee828a9693b I also think there's a faster way to do the `PolygonPolygonClosestLine` logic. Right now it iterates over each side of the polygon, draws a line, and returns the shortest result. Potentially it could use SAT to determine the closest sides, but I had unexpected results ```ts PolygonPolygonClosestLine(polygonA: PolygonCollider, polygonB: PolygonCollider) { const aSat = SeparatingAxis.findPolygonPolygonSeparation(polygonA, polygonB); const bSat = SeparatingAxis.findPolygonPolygonSeparation(polygonB, polygonA); return ClosestLine2(aSat.side, bSat.side); } ``` https://github.com/user-attachments/assets/be6460cb-7786-4864-93aa-d8053478aa53
- Loading branch information
1 parent
950272a
commit 2745795
Showing
2 changed files
with
80 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters