Skip to main content

raygeo.geo.algo.minkowski

Minkowski sum operations for 2D polygon toolpath generation.

Provides convolution of point sequences and segments, Minkowski sums for convex polygons, and no-fit polygon / inner fit polygon calculations used in nesting and packing algorithms.

Functions

calculate_input_scale()

calculate_input_scale(polygons: collections.abc.Sequence[collections.abc.Sequence[types.Point]], max_int: int = 2147483647) -> float

Calculate the optimal input scale for clipper operations.

Returns: Optimal scale factor.

ParameterTypeDescription
polygonscollections.abc.Sequence[collections.abc.Sequence[types.Point]]List of polygons to scale.
max_intint = 2147483647Maximum integer value for Clipper.
Returnsfloat

convolve_point_sequences()

convolve_point_sequences(seq_a: collections.abc.Sequence[tuple[int, int]], seq_b: collections.abc.Sequence[tuple[int, int]]) -> list[list[tuple[int, int]]]

Convolve two sequences of points.

Returns: Convolved point sequences.

ParameterTypeDescription
seq_acollections.abc.Sequence[tuple[int, int]]First sequence of integer points.
seq_bcollections.abc.Sequence[tuple[int, int]]Second sequence of integer points.
Returnslist[list[tuple[int, int]]]

convolve_two_segments()

convolve_two_segments(a1: tuple[int, int], a2: tuple[int, int], b1: tuple[int, int], b2: tuple[int, int]) -> list[tuple[int, int]]

Convolve two line segments.

Returns: Convolved point sequence.

ParameterTypeDescription
a1tuple[int, int]Start point of segment A.
a2tuple[int, int]End point of segment A.
b1tuple[int, int]Start point of segment B.
b2tuple[int, int]End point of segment B.
Returnslist[tuple[int, int]]

get_inner_fit_polygon()

get_inner_fit_polygon(outer: collections.abc.Sequence[types.Point], inner: collections.abc.Sequence[types.Point]) -> list[types.Polygon]

Compute the inner fit polygon (no-fit polygon for nesting).

Returns: Inner fit polygon.

ParameterTypeDescription
outercollections.abc.Sequence[types.Point]Outer polygon as (x, y) points.
innercollections.abc.Sequence[types.Point]Inner polygon as (x, y) points.
Returnslist[types.Polygon]

get_no_fit_polygon()

get_no_fit_polygon(subject: collections.abc.Sequence[types.Point], tool: collections.abc.Sequence[types.Point]) -> list[types.Polygon]

Compute the no-fit polygon for two 2D polygons.

Returns: No-fit polygon.

ParameterTypeDescription
subjectcollections.abc.Sequence[types.Point]Subject polygon as (x, y) points.
toolcollections.abc.Sequence[types.Point]Tool polygon as (x, y) points.
Returnslist[types.Polygon]

get_polygon_minkowski_sum_convex()

get_polygon_minkowski_sum_convex(poly_a: collections.abc.Sequence[tuple[int, int]], poly_b: collections.abc.Sequence[tuple[int, int]]) -> list[list[tuple[int, int]]]

Compute the Minkowski sum of two convex polygons.

Returns: Minkowski sum as list of polygons.

ParameterTypeDescription
poly_acollections.abc.Sequence[tuple[int, int]]First convex polygon as integer points.
poly_bcollections.abc.Sequence[tuple[int, int]]Second convex polygon as integer points.
Returnslist[list[tuple[int, int]]]