Skip to main content

Module offset

Module offset 

Source
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

  1. Ensure CCW winding
  2. Offset each edge by translating along its outward normal
  3. Compute miter joins at consecutive offset edges
  4. Apply miter limit – bevel if ratio exceeds threshold
  5. 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 distance using the default miter limit (2.0).
offset_polygon_miter
Offsets a simple polygon by distance with a configurable miter limit.