Expand description
Polygon offset via raw edge offset with miter/bevel joins.
Offsets a simple polygon by moving each edge along its outward normal, then computing miter (or bevel) joins at vertices. Self-intersections in the raw offset are detected and resolved by splitting into sub-loops and filtering by signed area.
§Algorithm
- Ensure CCW winding
- Offset each edge by translating along its outward normal
- Compute miter joins at consecutive offset edges
- Apply miter limit – bevel if ratio exceeds threshold
- Detect and resolve self-intersections
§Complexity
O(n^2) worst case for self-intersection resolution on concave polygons, O(n) for convex polygons.
§References
- Held (1998), “On the Computational Geometry of Pocket Machining”, Ch. 3
- Chen & McMains (2005), “Polygon Offsetting by Computing Winding Numbers”
Functions§
- line_
intersection - Computes the intersection of two lines defined by point + direction.
- offset_
edge - Offsets a single directed edge segment by translating along its outward normal.
- offset_
polygon - Offsets a simple polygon by
distanceusing the default miter limit (2.0). - offset_
polygon_ miter - Offsets a simple polygon by
distancewith a configurable miter limit.