Add Fillet 2D#1727
Conversation
ProblemAfter collecting all locally-valid fillet circles, we still need to verify that each circle is globally valid. This is done by checking whether any other polygon edge intersects the fillet circle. However, this check becomes numerically unstable in cases where three edges are close enough that the three fillet arcs almost form a complete circle. The left side of the figure below shows this unstable case. The right side is the result after clustering. Currently my best solution is to avoid validating these nearly-identical circles independently. Instead, I first collect fillet circles whose geometry is close enough, then force their circle centers to be exactly the same point before running the global validity check. This makes the intersection test more stable for the near-complete-circle case. The part I am least confident is when finding geometrically similar circles will introduce a manually chosen threshold. ReproducingThe test in figure might be reproduce by running --gtest_filter=Polygon.Fillet.UShape with radius = 1.2368517001458557. This branch has a predefined The key switches are: Relevant codeThe most relevant code is in these two sections Circle clustering logic: Global validity: |
|
Okay, I've finally read through your code, more or less. I'm going to summarize the architecture I see, just hitting the high points.
First, this code needs to be much shorter and simpler to be readable and debuggable. Make your primary named functions process single items, rather than vectors of them, and avoid lambdas to make it clearer what your function's inputs and outputs are. There will be no epsilons in this code. The most important function you need is Adjust your architecture:
Note also that there's no need for epsilon in checking for convexity: we don't want nearly colinear angles anyway. |
|
Thanks for the detailed review! It took me a little time to move past my original approach and think through whether this also applies to cases where four or more edges enclose a circle. After considering it, doing a set of three way is cleaner and more robust than clustering or detecting a closed-loop. I’ll start implementing it right away. |

This work aims to build a robust fillet algorithm for 2D polygons, inspired by the "rolling ball" method. Currently, the algorithm successfully processes 86 out of 108 test cases. Each test case consists of 12 subtests using different radius, which are scaled relative to the polygon's bounding box. As some cases are particularly complex, we are continuing to refine the algorithm to improve its overall robustness.