pyboxbuilder.paths

Polygon helpers for the rectilinear outlines the packer produces.

Leftover space between axis-aligned boxes is always rectilinear — every edge runs along X or Y — which makes exact offsetting a few lines of arithmetic rather than a job for a general polygon-offset library. Both the spacer pass (clearance around a tray) and PathBox (a tray’s inner cavity) need it.

Functions

bounds

(min corner, max corner) of an outline.

inset_rectilinear

Pull a rectilinear outline inward by distance.

is_rectilinear

Return True when every edge is axis-aligned.

largest_inscribed_rectangle

Find the largest axis-aligned inscribed rectangle in a simple polygon.

longest_inscribed_rectangle

Find the inscribed rectangle with the longest span (max(width, length)) in a simple polygon.

point_in_polygon

Return True if point (x, y) is inside the polygon by ray casting.

polygon_area

Shoelace area of a closed outline.

polygon_convex_corners

Return indices of convex vertices (outer corners) of a closed polygon path.

polygon_opposite_corners

Return indices of two opposite convex corners (furthest apart) of a polygon.

signed_area

Twice the signed area — positive when the outline runs counter-clockwise.