offset_polygon

compas.geometry.offset_polygon(polygon, distance, tol=1e-06)[source]

Offset a polygon (closed) by a distance.

Parameters
  • polygon (list of point) – The XYZ coordinates of the corners of the polygon. The first and last coordinates must not be identical.

  • distance (float or list of float) – The offset distance as float. A single value determines a constant offset globally. Alternatively, pairs of local offset values per line segment can be used to create variable offsets. Distance > 0: offset to the outside, distance < 0: offset to the inside.

Returns

offset polygon (list of point) – The XYZ coordinates of the corners of the offset polygon. The first and last coordinates are identical.

Notes

The offset direction is determined by the normal of the polygon. If the polygon is in the XY plane and the normal is along the positive Z axis, positive offset distances will result in an offset towards the inside of the polygon.

The algorithm works also for spatial polygons that do not perfectly fit a plane.

Examples

>>>