raygeo.geo.shape.polygon
JoinStyle
Corner join style for polygon offset operations.
JoinStyle.Miter: Extends edges until they meet (default).JoinStyle.Round: Adds a circular arc at the corner.JoinStyle.Square: Extends edges by the offset distance.
Functions
apply_minimum_curvature()
apply_minimum_curvature(
polygon: Sequence[types.Point],
r_min: float,
) -> list[types.Polygon]
Fillet tight internal corners to a minimum radius.
Offsets inward by r_min (Miter), then outward by r_min (Round). Acts as a high-pass curvature
filter — sharp corners are rounded to exactly r_min while the overall shape is preserved.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
r_min | float | Minimum allowed curvature radius. |
| Returns | list[types.Polygon] | Filleted polygon(s). |
| Complexity | O(n) |

Minimum curvature fillet applied to a triangle
clean_polygon()
clean_polygon(
polygon: Sequence[types.Point],
tolerance: Optional[float] = None,
) -> Optional[types.Polygon]
Clean a polygon by removing near-duplicate points.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Input polygon as (x, y) points. |
tolerance | Optional[float] = None | Distance tolerance for deduplication. |
| Returns | Optional[types.Polygon] | Cleaned polygon or None. |
| Complexity | O(n) |

clean_polygon removes near-duplicate vertices
do_polygons_intersect()
do_polygons_intersect(
p1: Sequence[types.Point],
p2: Sequence[types.Point],
min_area: float = 0,
) -> bool
Check if two polygons intersect.
| Parameter | Type | Description |
|---|---|---|
p1 | Sequence[types.Point] | First polygon as (x, y) points. |
p2 | Sequence[types.Point] | Second polygon as (x, y) points. |
min_area | float = 0 | Minimum intersection area threshold. |
| Returns | bool | True if polygons intersect. |
| Complexity | O(n * m) |
does_path_sweep_intersect_polygon()
does_path_sweep_intersect_polygon(
path: Sequence[types.Point],
radius: float,
obstacles: Sequence[types.Polygon],
) -> bool
Check if a disk swept along a path intersects any obstacle polygon.
Returns True when the Minkowski sweep of a disk of radius along path intersects any polygon in obstacles.
| Parameter | Type | Description |
|---|---|---|
path | Sequence[types.Point] | Open polyline as (x, y) points. |
radius | float | Disk radius. |
obstacles | Sequence[types.Polygon] | List of obstacle polygons. |
| Returns | bool | True if any obstacle intersects the sweep. |
| Complexity | O(n * m) |

Tests whether the Minkowski sweep of a disk along a polyline intersects any obstacle polygon
does_polygon_enclose_circle()
does_polygon_enclose_circle(
center: types.Point,
radius: float,
polygon: Sequence[types.Point],
) -> bool
Check if a polygon fully encloses a circle.
Uses a conservative fast check: the polygon's AABB must contain the circle's AABB, and the circle center must be inside the polygon.
| Parameter | Type | Description |
|---|---|---|
center | types.Point | Circle center (x, y). |
radius | float | Circle radius. |
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | bool | True if the polygon fully encloses the circle. |
| Complexity | O(n) |
flip_polygon()
flip_polygon(
polygon: Sequence[types.Point],
flip_h: bool,
flip_v: bool,
) -> types.Polygon
Flip a polygon horizontally and/or vertically.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
flip_h | bool | Whether to flip horizontally. |
flip_v | bool | Whether to flip vertically. |
| Returns | types.Polygon | Flipped polygon. |
| Complexity | O(n) |
flip_polygon_numpy()
flip_polygon_numpy(
polygon: numpy.NDArray,
flip_h: bool,
flip_v: bool,
) -> numpy.NDArray
Flip a polygon from numpy array.
| Parameter | Type | Description |
|---|---|---|
polygon | numpy.NDArray | Polygon as a 2D numpy array. |
flip_h | bool | Whether to flip horizontally. |
flip_v | bool | Whether to flip vertically. |
| Returns | numpy.NDArray | Flipped polygon as numpy array. |
| Complexity | O(n) |
flip_polygons()
flip_polygons(
polygons: Sequence[types.Polygon],
flip_h: bool,
flip_v: bool,
) -> list[types.Polygon]
Flip multiple polygons.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[types.Polygon] | List of polygons to flip. |
flip_h | bool | Whether to flip horizontally. |
flip_v | bool | Whether to flip vertically. |
| Returns | list[types.Polygon] | Flipped polygons. |
| Complexity | O(n * m) |
flip_polygons_numpy()
flip_polygons_numpy(
polygons: Sequence[numpy.NDArray],
flip_h: bool,
flip_v: bool,
) -> list[numpy.NDArray]
Flip polygons from numpy arrays.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[numpy.NDArray] | List of 2D numpy arrays. |
flip_h | bool | Whether to flip horizontally. |
flip_v | bool | Whether to flip vertically. |
| Returns | list[numpy.NDArray] | List of flipped numpy arrays. |
| Complexity | O(n * m) |
get_circle_polygon()
get_circle_polygon(
center: types.Point,
radius: float,
n: int = 64,
) -> types.Polygon
Approximate a circle as an n-gon polygon.
| Parameter | Type | Description |
|---|---|---|
center | types.Point | Centre point (x, y). |
radius | float | Circle radius. |
n | int = 64 | Number of sides (default 64). |
| Returns | types.Polygon | Polygon as list of (x, y) points. |
| Complexity | O(n) |

get_circle_polygon approximates a circle as an n-sided polygon
get_miter_offset_intersection()
get_miter_offset_intersection(
v: types.Point,
off_a: types.Point,
dir_a: types.Point,
off_b: types.Point,
dir_b: types.Point,
) -> types.Point
Intersect two offset lines at a vertex for miter join.
Line A: v + off_a + t * dir_a Line B: v + off_b + s * dir_b
Returns the intersection point. When the lines are nearly parallel falls back to v + off_a.
| Parameter | Type | Description |
|---|---|---|
v | types.Point | Vertex point (x, y). |
off_a | types.Point | Offset from v along line A. |
dir_a | types.Point | Unit direction vector of line A. |
off_b | types.Point | Offset from v along line B. |
dir_b | types.Point | Unit direction vector of line B. |
| Returns | types.Point | Intersection point (x, y). |
get_point_line_distance()
get_point_line_distance(
point: types.Point,
line_start: types.Point,
line_end: types.Point,
) -> float
Compute the distance from a point to a line.
| Parameter | Type | Description |
|---|---|---|
point | types.Point | Point (x, y). |
line_start | types.Point | Line start point (x, y). |
line_end | types.Point | Line end point (x, y). |
| Returns | float | Perpendicular distance. |
| Complexity | O(1) |
get_polygon_area()
get_polygon_area(polygon: Sequence[types.Point]) -> float
Get the unsigned area of a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | float | Unsigned area. |
| Complexity | O(n) |
get_polygon_boundary_distance()
get_polygon_boundary_distance(
a: Sequence[tuple[float, float]],
b: Sequence[tuple[float, float]],
) -> float
Minimum midpoint-to-segment distance between the boundaries of two polygons.
Uses segment midpoints rather than raw segment-segment distance to avoid false positives from polygons that merely touch at a shared vertex.
| Parameter | Type | Description |
|---|---|---|
a | Sequence[tuple[float, float]] | First polygon as (x, y) points. |
b | Sequence[tuple[float, float]] | Second polygon as (x, y) points. |
| Returns | float | Minimum boundary distance. |
| Complexity | O(n * m) |
get_polygon_bounds()
get_polygon_bounds(polygon: Sequence[types.Point]) -> types.Rect
Get the bounding rectangle of a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | types.Rect | Bounding rectangle as (x_min, y_min, x_max, y_max). |
| Complexity | O(n) |
get_polygon_centroid()
get_polygon_centroid(polygon: Sequence[types.Point]) -> types.Point
Get the centroid of a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | types.Point | Centroid point (x, y). |
| Complexity | O(n) |

get_polygon_centroid computes the geometric center
get_polygon_closest_point()
get_polygon_closest_point(
polygon: Sequence[types.Point],
x: float,
y: float,
) -> tuple[float, tuple[float, float], float] | None
Find the closest point on a polygon boundary to (x, y).
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
x | float | X coordinate. |
y | float | Y coordinate. |
| Returns | tuple[float, tuple[float, float], float] | None | (t, (cx, cy), distance_squared) or None if degenerate. |

get_polygon_closest_point finds the nearest boundary point to a given coordinate
get_polygon_convex_hull()
get_polygon_convex_hull(polygon: Sequence[types.Point]) -> types.Polygon
Get the convex hull of a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | types.Polygon | Convex hull as list of points. |
| Complexity | O(n log n) |

get_polygon_convex_hull wraps polygon in convex hull
get_polygon_edges()
get_polygon_edges(
polygon: Sequence[types.Point],
) -> list[tuple[types.Point, types.Point]]
Get the edges of a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | list[tuple[types.Point, types.Point]] | List of ((x1, y1), (x2, y2)) edges. |
| Complexity | O(n) |
get_polygon_group_bounds()
get_polygon_group_bounds(polygons: Sequence[types.Polygon]) -> types.Rect
Get the bounding rectangle of a group of polygons.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[types.Polygon] | List of polygons. |
| Returns | types.Rect | Bounding rectangle as (x_min, y_min, x_max, y_max). |
| Complexity | O(n * m) |

get_polygon_group_bounds all polygons within a rect
get_polygon_heading_at()
get_polygon_heading_at(
polygon: list[tuple[float, float]],
vertex: tuple[float, float],
) -> float
| Parameter | Type | Description |
|---|---|---|
polygon | list[tuple[float, float]] | |
vertex | tuple[float, float] | |
| Returns | float |

get_polygon_heading_at draws outward-facing heading arrows at each vertex of a CCW polygon.
get_polygon_perimeter()
get_polygon_perimeter(polygon: Sequence[types.Point]) -> float
Get the perimeter of a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | float | Perimeter length. |
| Complexity | O(n) |
get_polygon_signed_area()
get_polygon_signed_area(polygon: Sequence[types.Point]) -> float
Get the signed area of a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | float | Signed area (positive for CCW, negative for CW). |
| Complexity | O(n) |
get_polygon_vertex_centroid()
get_polygon_vertex_centroid(
polygon: Sequence[tuple[float, float]],
) -> tuple[float, float]
Arithmetic mean of polygon vertices (vertex-average centroid).
Unlike get_polygon_centroid (area-weighted shoelace centroid), this is useful for concave polygons where the area centroid lies outside the boundary.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[tuple[float, float]] | Polygon as (x, y) points. |
| Returns | tuple[float, float] | Vertex-average centroid (x, y). |
| Complexity | O(n) |
get_polygons_closest_point()
get_polygons_closest_point(
polygons: Sequence[types.Polygon],
x: float,
y: float,
) -> tuple[int, float, tuple[float, float], float] | None
Find the closest point on any polygon in a list to (x, y).
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[types.Polygon] | List of polygons as (x, y) points. |
x | float | X coordinate. |
y | float | Y coordinate. |
| Returns | tuple[int, float, tuple[float, float], float] | None | (polygon_index, t, (cx, cy), distance_squared) or None. |
get_polygons_difference()
get_polygons_difference(
poly1: Sequence[types.Point],
poly2: Sequence[types.Point],
) -> list[types.Polygon]
Get the difference of two polygons.
| Parameter | Type | Description |
|---|---|---|
poly1 | Sequence[types.Point] | First polygon as (x, y) points. |
poly2 | Sequence[types.Point] | Second polygon to subtract. |
| Returns | list[types.Polygon] | Difference polygon(s). |
| Complexity | O(n log n) |

Polygon difference
get_polygons_group_difference()
get_polygons_group_difference(
subject: Sequence[types.Polygon],
clip: Sequence[types.Polygon],
) -> list[types.Polygon]
Subtract clip polygons from subject polygons.
| Parameter | Type | Description |
|---|---|---|
subject | Sequence[types.Polygon] | Subject polygons. |
clip | Sequence[types.Polygon] | Clip polygons to subtract. |
| Returns | list[types.Polygon] | Difference polygon(s). |
| Complexity | O(n log n) |
get_polygons_group_intersection()
get_polygons_group_intersection(
subject: Sequence[types.Polygon],
clip: Sequence[types.Polygon],
) -> list[types.Polygon]
Intersect two groups of polygons (subject & clip).
| Parameter | Type | Description |
|---|---|---|
subject | Sequence[types.Polygon] | Subject polygons. |
clip | Sequence[types.Polygon] | Clip polygons. |
| Returns | list[types.Polygon] | Intersection polygon(s). |
| Complexity | O(n log n) |
get_polygons_intersection()
get_polygons_intersection(
poly1: Sequence[types.Point],
poly2: Sequence[types.Point],
) -> list[types.Polygon]
Get the intersection of two polygons.
| Parameter | Type | Description |
|---|---|---|
poly1 | Sequence[types.Point] | First polygon as (x, y) points. |
poly2 | Sequence[types.Point] | Second polygon as (x, y) points. |
| Returns | list[types.Polygon] | Intersection polygon(s). |
| Complexity | O(n log n) |

Polygon intersection
get_polygons_union()
get_polygons_union(polygons: Sequence[types.Polygon]) -> list[types.Polygon]
Get the union of multiple polygons.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[types.Polygon] | List of polygons to union. |
| Returns | list[types.Polygon] | Union polygon(s). |
| Complexity | O(n log n) |

Polygon union
get_polyline_swept_polygon()
get_polyline_swept_polygon(
path: Sequence[types.Point],
radius: float,
) -> list[types.Polygon]
Compute the Minkowski sum of a polyline path with a disk.
Returns a single polygon covering the swept area — the union of segment-wide rectangular strips capped with half-circles at the first and last endpoints.
| Parameter | Type | Description |
|---|---|---|
path | Sequence[types.Point] | Open polyline as (x, y) points. |
radius | float | Offset radius. |
| Returns | list[types.Polygon] | A single swept polygon. |
| Complexity | O(n) |

get_polyline_swept_polygon computes the Minkowski sum of a polyline path with a disk
get_segment_swept_polygon()
get_segment_swept_polygon(
a: types.Point,
b: types.Point,
radius: float,
) -> list[types.Polygon]
Compute the swept area of a line segment with a given radius.
Returns a rectangle (the Minkowski sum of the segment with a disk of radius) plus two disks at the endpoints. Useful for toolpath clearance tracking and roughing simulation.
| Parameter | Type | Description |
|---|---|---|
a | types.Point | Start point (x, y). |
b | types.Point | End point (x, y). |
radius | float | Offset radius. |
| Returns | list[types.Polygon] | List of polygons (rectangle + two end-caps). |
| Complexity | O(n) |

get_segment_swept_polygon computes the swept area of a line segment with a given radius
get_signed_boundary_distance()
get_signed_boundary_distance(
point: tuple[float, float],
polygons: Sequence[Sequence[tuple[float, float]]],
) -> float
Signed perpendicular distance from point to nearest polygon boundary.
Positive = outside all polygons, Negative = inside any polygon, Zero = exactly on a boundary.
| Parameter | Type | Description |
|---|---|---|
point | tuple[float, float] | Query point (x, y). |
polygons | Sequence[Sequence[tuple[float, float]]] | List of polygons. |
| Returns | float | Signed distance (mm). |

Signed distance field around a square polygon. Red = outside (positive), blue = inside (negative), black contour marks the boundary.
is_almost_equal()
is_almost_equal(a: float, b: float, tolerance: Optional[float] = None) -> bool
Check if two floats are almost equal.
| Parameter | Type | Description |
|---|---|---|
a | float | First float. |
b | float | Second float. |
tolerance | Optional[float] = None | Comparison tolerance. |
| Returns | bool | True if |
| Complexity | O(1) |
is_point_inside_polygon()
is_point_inside_polygon(
point: types.Point,
polygon: Sequence[types.Point],
) -> bool
Check if a point is inside a polygon.
| Parameter | Type | Description |
|---|---|---|
point | types.Point | Point (x, y) to test. |
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | bool | True if point is inside the polygon. |
| Complexity | O(n) |
is_polygon_clockwise()
is_polygon_clockwise(points: Sequence[types.Point2DOr3D]) -> bool
Check if a polygon has clockwise winding.
| Parameter | Type | Description |
|---|---|---|
points | Sequence[types.Point2DOr3D] | Sequence of (x, y) or (x, y, z) points. |
| Returns | bool | True if the polygon is clockwise. |
| Complexity | O(n) |
is_polygon_convex()
is_polygon_convex(polygon: Sequence[types.Point]) -> bool
Check if a polygon is convex.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
| Returns | bool | True if the polygon is convex. |
| Complexity | O(n) |
normalize_polygons()
normalize_polygons(
polygons: Sequence[types.Polygon],
) -> tuple[list[types.Polygon], float, float]
Normalize polygons (outer CCW, inner CW).
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[types.Polygon] | List of polygons to normalize. |
| Returns | tuple[list[types.Polygon], float, float] | Tuple of (normalized_polygons, min_x, min_y). |
| Complexity | O(n log n) |
normalize_polygons_numpy()
normalize_polygons_numpy(
polygons: Sequence[numpy.NDArray],
) -> tuple[list[numpy.NDArray], float, float]
Normalize polygons from numpy arrays.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[numpy.NDArray] | Sequence of 2D numpy arrays. |
| Returns | tuple[list[numpy.NDArray], float, float] | Tuple of (normalized_arrays, min_x, min_y). |
| Complexity | O(n log n) |
offset_polygon()
offset_polygon(
polygon: Sequence[types.Point],
offset: float,
join_style: JoinStyle = JoinStyle.Miter,
) -> list[types.Polygon]
Offset (inflate/deflate) a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
offset | float | Offset distance (positive to inflate, negative to deflate). |
join_style | JoinStyle = JoinStyle.Miter | Corner join style (default: JoinStyle.Miter). |
| Returns | list[types.Polygon] | Offset polygon(s). |
| Complexity | O(n log n) |

Polygon offset — miter vs round vs square join styles
point_in_polygon_numpy()
point_in_polygon_numpy(point: types.Point, polygon: numpy.NDArray) -> bool
Check if point is in polygon from numpy array.
| Parameter | Type | Description |
|---|---|---|
point | types.Point | Point (x, y) to test. |
polygon | numpy.NDArray | Polygon as a 2D numpy array. |
| Returns | bool | True if point is inside the polygon. |
| Complexity | O(n) |
polygon_area_numpy()
polygon_area_numpy(polygon: numpy.NDArray) -> float
Get the area of a polygon from numpy array.
| Parameter | Type | Description |
|---|---|---|
polygon | numpy.NDArray | Polygon as a 2D numpy array. |
| Returns | float | Signed area. |
| Complexity | O(n) |
polygon_bounds_numpy()
polygon_bounds_numpy(polygon: numpy.NDArray) -> types.Rect
Get bounds of a polygon from numpy array.
| Parameter | Type | Description |
|---|---|---|
polygon | numpy.NDArray | Polygon as a 2D numpy array. |
| Returns | types.Rect | Bounding rectangle as (x_min, y_min, x_max, y_max). |
| Complexity | O(n) |
polygon_group_bounds_numpy()
polygon_group_bounds_numpy(polygons: Sequence[numpy.NDArray]) -> types.Rect
Get bounds of polygon group from numpy arrays.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[numpy.NDArray] | Sequence of 2D numpy arrays. |
| Returns | types.Rect | Bounding rectangle as (x_min, y_min, x_max, y_max). |
| Complexity | O(n * m) |
polygon_perimeter_numpy()
polygon_perimeter_numpy(polygon: numpy.NDArray) -> float
Get the perimeter of a polygon from numpy array.
| Parameter | Type | Description |
|---|---|---|
polygon | numpy.NDArray | Polygon as a 2D numpy array. |
| Returns | float | Perimeter length. |
| Complexity | O(n) |
polygons_intersect_numpy()
polygons_intersect_numpy(
poly1: numpy.NDArray,
poly2: numpy.NDArray,
min_area: float = 0,
) -> bool
Check if polygons intersect from numpy arrays.
| Parameter | Type | Description |
|---|---|---|
poly1 | numpy.NDArray | First polygon as a 2D numpy array. |
poly2 | numpy.NDArray | Second polygon as a 2D numpy array. |
min_area | float = 0 | Minimum intersection area threshold. |
| Returns | bool | True if polygons intersect. |
| Complexity | O(n * m) |
resample_polygon()
resample_polygon(
polygon: Sequence[tuple[float, float]],
spacing: float,
) -> list[tuple[float, float]]
Resample a closed polygon by inserting evenly-spaced points along each edge so that no segment is longer than spacing.
The result is a closed polyline (last point connects back to first conceptually, but is not duplicated).
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[tuple[float, float]] | Polygon as (x, y) points. |
spacing | float | Maximum allowed segment length. |
| Returns | list[tuple[float, float]] | Resampled polygon as list of (x, y) points. |
| Complexity | O(n * m) |
rotate_polygon()
rotate_polygon(polygon: Sequence[types.Point], angle: float) -> types.Polygon
Rotate a polygon by an angle.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
angle | float | Rotation angle in degrees. |
| Returns | types.Polygon | Rotated polygon. |
| Complexity | O(n) |
rotate_polygon_numpy()
rotate_polygon_numpy(polygon: numpy.NDArray, angle: float) -> numpy.NDArray
Rotate a polygon from numpy array.
| Parameter | Type | Description |
|---|---|---|
polygon | numpy.NDArray | Polygon as a 2D numpy array. |
angle | float | Rotation angle in degrees. |
| Returns | numpy.NDArray | Rotated polygon as numpy array. |
| Complexity | O(n) |
rotate_polygons()
rotate_polygons(
polygons: Sequence[types.Polygon],
angle: float,
) -> list[types.Polygon]
Rotate multiple polygons by an angle.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[types.Polygon] | List of polygons to rotate. |
angle | float | Rotation angle in degrees. |
| Returns | list[types.Polygon] | Rotated polygons. |
| Complexity | O(n * m) |
rotate_polygons_numpy()
rotate_polygons_numpy(
polygons: Sequence[numpy.NDArray],
angle: float,
) -> list[numpy.NDArray]
Rotate polygons from numpy arrays.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[numpy.NDArray] | Sequence of 2D numpy arrays. |
angle | float | Rotation angle in degrees. |
| Returns | list[numpy.NDArray] | List of rotated numpy arrays. |
| Complexity | O(n * m) |
scale_polygon()
scale_polygon(
polygon: Sequence[types.Point],
scale: float,
scale_y: Optional[float] = None,
) -> types.Polygon
Scale a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
scale | float | X (and Y if scale_y is None) scale factor. |
scale_y | Optional[float] = None | Y scale factor (optional). |
| Returns | types.Polygon | Scaled polygon. |
| Complexity | O(n) |
to_clipper_numpy()
to_clipper_numpy(polygon: Sequence[numpy.NDArray]) -> list[tuple[int, int]]
Convert a numpy polygon to Clipper integer coordinates.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[numpy.NDArray] | Sequence of 2D numpy arrays. |
| Returns | list[tuple[int, int]] | List of (x, y) integer tuples. |
| Complexity | O(n * m) |
translate_bounds()
translate_bounds(bounds: types.Rect, dx: float, dy: float) -> types.Rect
Translate a bounding rectangle.
| Parameter | Type | Description |
|---|---|---|
bounds | types.Rect | Bounding rectangle (x_min, y_min, x_max, y_max). |
dx | float | X translation. |
dy | float | Y translation. |
| Returns | types.Rect | Translated bounding rectangle. |
| Complexity | O(1) |
translate_polygon()
translate_polygon(
polygon: Sequence[types.Point],
dx: float,
dy: float,
) -> types.Polygon
Translate a polygon.
| Parameter | Type | Description |
|---|---|---|
polygon | Sequence[types.Point] | Polygon as (x, y) points. |
dx | float | X translation. |
dy | float | Y translation. |
| Returns | types.Polygon | Translated polygon. |
| Complexity | O(n) |
translate_polygon_numpy()
translate_polygon_numpy(
polygon: numpy.NDArray,
dx: float,
dy: float,
) -> numpy.NDArray
Translate a polygon from numpy array.
| Parameter | Type | Description |
|---|---|---|
polygon | numpy.NDArray | Polygon as a 2D numpy array. |
dx | float | X translation. |
dy | float | Y translation. |
| Returns | numpy.NDArray | Translated polygon as numpy array. |
| Complexity | O(n) |
translate_polygons()
translate_polygons(
polygons: Sequence[types.Polygon],
dx: float,
dy: float,
) -> list[types.Polygon]
Translate a list of polygons.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[types.Polygon] | List of polygons to translate. |
dx | float | X translation. |
dy | float | Y translation. |
| Returns | list[types.Polygon] | Translated polygons. |
| Complexity | O(n * m) |
translate_polygons_numpy()
translate_polygons_numpy(
polygons: Sequence[numpy.NDArray],
dx: float,
dy: float,
) -> list[numpy.NDArray]
Translate polygons from numpy arrays.
| Parameter | Type | Description |
|---|---|---|
polygons | Sequence[numpy.NDArray] | Sequence of 2D numpy arrays. |
dx | float | X translation. |
dy | float | Y translation. |
| Returns | list[numpy.NDArray] | List of translated numpy arrays. |
| Complexity | O(n * m) |
walk_polygon_from_point()
walk_polygon_from_point(
polygon: list[tuple[float, float]],
start: tuple[float, float],
) -> list[tuple[int, float, float]]
| Parameter | Type | Description |
|---|---|---|
polygon | list[tuple[float, float]] | |
start | tuple[float, float] | |
| Returns | list[tuple[int, float, float]] |

walk_polygon_from_point returns vertices in walk order starting from the vertex closest to a
marker.
walk_polygon_vertices()
walk_polygon_vertices(
polygon: list[tuple[float, float]],
start_idx: int,
forward: bool,
) -> list[tuple[int, float, float]]
| Parameter | Type | Description |
|---|---|---|
polygon | list[tuple[float, float]] | |
start_idx | int | |
forward | bool | |
| Returns | list[tuple[int, float, float]] |