Skip to main content

offset_polygon_2d

Function offset_polygon_2d 

Source
pub fn offset_polygon_2d(polygon: &[[f64; 2]], delta: f64) -> Vec<[f64; 2]>
Expand description

Offset a 2D polygon outward by delta (positive) or inward by |delta| (negative).

Each edge is displaced by delta in its outward normal direction. The offset polygon is computed by offsetting each edge and re-intersecting adjacent pairs. This is the Minkowski sum with a disk of radius |delta| for convex polygons.

Returns the offset polygon or an empty vector if degenerate.