跳转到主要内容

raygeo.geo.algo.nest2d.nfp

No-Fit Polygon calculation for nesting algorithms.

Provides functions for computing No-Fit Polygons (NFP) using Minkowski sums, both for convex and general polygon pairs.

Functions

nfp_minkowski()

nfp_minkowski(
static_poly: Sequence[tuple[float, float]],
orbiting: Sequence[tuple[float, float]],
) -> list[list[tuple[float, float]]]

General NFP using Minkowski sum with Clipper union.

ParameterTypeDescription
static_polySequence[tuple[float, float]]Static polygon as points.
orbitingSequence[tuple[float, float]]Orbiting polygon as points.
Returnslist[list[tuple[float, float]]]List of NFP polygons.
ComplexityO(n * m) where n, m = vertex counts.

no_fit_polygon()

no_fit_polygon(
static_poly: Sequence[types.Point],
orbiting: Sequence[types.Point],
) -> list[types.Polygon]

Compute the No-Fit Polygon (NFP) for two polygons.

ParameterTypeDescription
static_polySequence[types.Point]Static polygon as (x, y) points.
orbitingSequence[types.Point]Orbiting polygon as (x, y) points.
Returnslist[types.Polygon]List of NFP polygons.
ComplexityO(n * m) where n, m = vertex counts of input polygons.

normalize_polygon()

normalize_polygon(
poly: Sequence[types.Point],
) -> tuple[types.Polygon, float, float]

Shift a polygon so its bounding box minimum is at (0, 0).

ParameterTypeDescription
polySequence[types.Point]Input polygon as (x, y) points.
Returnstuple[types.Polygon, float, float](normalized_polygon, offset_x, offset_y).
ComplexityO(n) where n = vertex count.

polygon_to_key()

polygon_to_key(poly: Sequence[types.Point]) -> list[tuple[int, int]]

Convert a polygon to a rounded integer key for caching.

ParameterTypeDescription
polySequence[types.Point]Input polygon as (x, y) points.
Returnslist[tuple[int, int]]List of rounded (x, y) integer tuples.
ComplexityO(n) where n = vertex count.