跳转到主要内容

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.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
r_minfloatMinimum allowed curvature radius.
Returnslist[types.Polygon]Filleted polygon(s).
ComplexityO(n)

Minimum curvature fillet applied to a triangle

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.

ParameterTypeDescription
polygonSequence[types.Point]Input polygon as (x, y) points.
toleranceOptional[float] = NoneDistance tolerance for deduplication.
ReturnsOptional[types.Polygon]Cleaned polygon or None.
ComplexityO(n)

 removes near-duplicate vertices

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.

ParameterTypeDescription
p1Sequence[types.Point]First polygon as (x, y) points.
p2Sequence[types.Point]Second polygon as (x, y) points.
min_areafloat = 0Minimum intersection area threshold.
ReturnsboolTrue if polygons intersect.
ComplexityO(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.

ParameterTypeDescription
pathSequence[types.Point]Open polyline as (x, y) points.
radiusfloatDisk radius.
obstaclesSequence[types.Polygon]List of obstacle polygons.
ReturnsboolTrue if any obstacle intersects the sweep.
ComplexityO(n * m)

Tests whether the Minkowski sweep of a disk along a polyline intersects any obstacle polygon

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.

ParameterTypeDescription
centertypes.PointCircle center (x, y).
radiusfloatCircle radius.
polygonSequence[types.Point]Polygon as (x, y) points.
ReturnsboolTrue if the polygon fully encloses the circle.
ComplexityO(n)

flip_polygon()

flip_polygon(
polygon: Sequence[types.Point],
flip_h: bool,
flip_v: bool,
) -> types.Polygon

Flip a polygon horizontally and/or vertically.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
flip_hboolWhether to flip horizontally.
flip_vboolWhether to flip vertically.
Returnstypes.PolygonFlipped polygon.
ComplexityO(n)

flip_polygon_numpy()

flip_polygon_numpy(
polygon: numpy.NDArray,
flip_h: bool,
flip_v: bool,
) -> numpy.NDArray

Flip a polygon from numpy array.

ParameterTypeDescription
polygonnumpy.NDArrayPolygon as a 2D numpy array.
flip_hboolWhether to flip horizontally.
flip_vboolWhether to flip vertically.
Returnsnumpy.NDArrayFlipped polygon as numpy array.
ComplexityO(n)

flip_polygons()

flip_polygons(
polygons: Sequence[types.Polygon],
flip_h: bool,
flip_v: bool,
) -> list[types.Polygon]

Flip multiple polygons.

ParameterTypeDescription
polygonsSequence[types.Polygon]List of polygons to flip.
flip_hboolWhether to flip horizontally.
flip_vboolWhether to flip vertically.
Returnslist[types.Polygon]Flipped polygons.
ComplexityO(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.

ParameterTypeDescription
polygonsSequence[numpy.NDArray]List of 2D numpy arrays.
flip_hboolWhether to flip horizontally.
flip_vboolWhether to flip vertically.
Returnslist[numpy.NDArray]List of flipped numpy arrays.
ComplexityO(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.

ParameterTypeDescription
centertypes.PointCentre point (x, y).
radiusfloatCircle radius.
nint = 64Number of sides (default 64).
Returnstypes.PolygonPolygon as list of (x, y) points.
ComplexityO(n)

 approximates a circle as an n-sided polygon

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.

ParameterTypeDescription
vtypes.PointVertex point (x, y).
off_atypes.PointOffset from v along line A.
dir_atypes.PointUnit direction vector of line A.
off_btypes.PointOffset from v along line B.
dir_btypes.PointUnit direction vector of line B.
Returnstypes.PointIntersection 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.

ParameterTypeDescription
pointtypes.PointPoint (x, y).
line_starttypes.PointLine start point (x, y).
line_endtypes.PointLine end point (x, y).
ReturnsfloatPerpendicular distance.
ComplexityO(1)

get_polygon_area()

get_polygon_area(polygon: Sequence[types.Point]) -> float

Get the unsigned area of a polygon.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
ReturnsfloatUnsigned area.
ComplexityO(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.

ParameterTypeDescription
aSequence[tuple[float, float]]First polygon as (x, y) points.
bSequence[tuple[float, float]]Second polygon as (x, y) points.
ReturnsfloatMinimum boundary distance.
ComplexityO(n * m)

get_polygon_bounds()

get_polygon_bounds(polygon: Sequence[types.Point]) -> types.Rect

Get the bounding rectangle of a polygon.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
Returnstypes.RectBounding rectangle as (x_min, y_min, x_max, y_max).
ComplexityO(n)

get_polygon_centroid()

get_polygon_centroid(polygon: Sequence[types.Point]) -> types.Point

Get the centroid of a polygon.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
Returnstypes.PointCentroid point (x, y).
ComplexityO(n)

 computes the geometric center

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).

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
xfloatX coordinate.
yfloatY coordinate.
Returnstuple[float, tuple[float, float], float] | None(t, (cx, cy), distance_squared) or None if degenerate.

 finds the nearest boundary point to a given coordinate

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.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
Returnstypes.PolygonConvex hull as list of points.
ComplexityO(n log n)

 wraps polygon in convex hull

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.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
Returnslist[tuple[types.Point, types.Point]]List of ((x1, y1), (x2, y2)) edges.
ComplexityO(n)

get_polygon_group_bounds()

get_polygon_group_bounds(polygons: Sequence[types.Polygon]) -> types.Rect

Get the bounding rectangle of a group of polygons.

ParameterTypeDescription
polygonsSequence[types.Polygon]List of polygons.
Returnstypes.RectBounding rectangle as (x_min, y_min, x_max, y_max).
ComplexityO(n * m)

 all polygons within a rect

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
ParameterTypeDescription
polygonlist[tuple[float, float]]
vertextuple[float, float]
Returnsfloat

 draws outward-facing heading arrows at each vertex of a CCW polygon.

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.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
ReturnsfloatPerimeter length.
ComplexityO(n)

get_polygon_signed_area()

get_polygon_signed_area(polygon: Sequence[types.Point]) -> float

Get the signed area of a polygon.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
ReturnsfloatSigned area (positive for CCW, negative for CW).
ComplexityO(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.

ParameterTypeDescription
polygonSequence[tuple[float, float]]Polygon as (x, y) points.
Returnstuple[float, float]Vertex-average centroid (x, y).
ComplexityO(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).

ParameterTypeDescription
polygonsSequence[types.Polygon]List of polygons as (x, y) points.
xfloatX coordinate.
yfloatY coordinate.
Returnstuple[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.

ParameterTypeDescription
poly1Sequence[types.Point]First polygon as (x, y) points.
poly2Sequence[types.Point]Second polygon to subtract.
Returnslist[types.Polygon]Difference polygon(s).
ComplexityO(n log n)

Polygon difference

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.

ParameterTypeDescription
subjectSequence[types.Polygon]Subject polygons.
clipSequence[types.Polygon]Clip polygons to subtract.
Returnslist[types.Polygon]Difference polygon(s).
ComplexityO(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).

ParameterTypeDescription
subjectSequence[types.Polygon]Subject polygons.
clipSequence[types.Polygon]Clip polygons.
Returnslist[types.Polygon]Intersection polygon(s).
ComplexityO(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.

ParameterTypeDescription
poly1Sequence[types.Point]First polygon as (x, y) points.
poly2Sequence[types.Point]Second polygon as (x, y) points.
Returnslist[types.Polygon]Intersection polygon(s).
ComplexityO(n log n)

Polygon intersection

Polygon intersection

get_polygons_union()

get_polygons_union(polygons: Sequence[types.Polygon]) -> list[types.Polygon]

Get the union of multiple polygons.

ParameterTypeDescription
polygonsSequence[types.Polygon]List of polygons to union.
Returnslist[types.Polygon]Union polygon(s).
ComplexityO(n log n)

Polygon union

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.

ParameterTypeDescription
pathSequence[types.Point]Open polyline as (x, y) points.
radiusfloatOffset radius.
Returnslist[types.Polygon]A single swept polygon.
ComplexityO(n)

 computes the Minkowski sum of a polyline path with a disk

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.

ParameterTypeDescription
atypes.PointStart point (x, y).
btypes.PointEnd point (x, y).
radiusfloatOffset radius.
Returnslist[types.Polygon]List of polygons (rectangle + two end-caps).
ComplexityO(n)

 computes the swept area of a line segment with a given radius

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.

ParameterTypeDescription
pointtuple[float, float]Query point (x, y).
polygonsSequence[Sequence[tuple[float, float]]]List of polygons.
ReturnsfloatSigned distance (mm).

Signed distance field around a square polygon. Red = outside (positive), blue = inside (negative), black contour marks the boundary.

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.

ParameterTypeDescription
afloatFirst float.
bfloatSecond float.
toleranceOptional[float] = NoneComparison tolerance.
ReturnsboolTrue if
ComplexityO(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.

ParameterTypeDescription
pointtypes.PointPoint (x, y) to test.
polygonSequence[types.Point]Polygon as (x, y) points.
ReturnsboolTrue if point is inside the polygon.
ComplexityO(n)

is_polygon_clockwise()

is_polygon_clockwise(points: Sequence[types.Point2DOr3D]) -> bool

Check if a polygon has clockwise winding.

ParameterTypeDescription
pointsSequence[types.Point2DOr3D]Sequence of (x, y) or (x, y, z) points.
ReturnsboolTrue if the polygon is clockwise.
ComplexityO(n)

is_polygon_convex()

is_polygon_convex(polygon: Sequence[types.Point]) -> bool

Check if a polygon is convex.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
ReturnsboolTrue if the polygon is convex.
ComplexityO(n)

normalize_polygons()

normalize_polygons(
polygons: Sequence[types.Polygon],
) -> tuple[list[types.Polygon], float, float]

Normalize polygons (outer CCW, inner CW).

ParameterTypeDescription
polygonsSequence[types.Polygon]List of polygons to normalize.
Returnstuple[list[types.Polygon], float, float]Tuple of (normalized_polygons, min_x, min_y).
ComplexityO(n log n)

normalize_polygons_numpy()

normalize_polygons_numpy(
polygons: Sequence[numpy.NDArray],
) -> tuple[list[numpy.NDArray], float, float]

Normalize polygons from numpy arrays.

ParameterTypeDescription
polygonsSequence[numpy.NDArray]Sequence of 2D numpy arrays.
Returnstuple[list[numpy.NDArray], float, float]Tuple of (normalized_arrays, min_x, min_y).
ComplexityO(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.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
offsetfloatOffset distance (positive to inflate, negative to deflate).
join_styleJoinStyle = JoinStyle.MiterCorner join style (default: JoinStyle.Miter).
Returnslist[types.Polygon]Offset polygon(s).
ComplexityO(n log n)

Polygon offset — miter vs round vs square join styles

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.

ParameterTypeDescription
pointtypes.PointPoint (x, y) to test.
polygonnumpy.NDArrayPolygon as a 2D numpy array.
ReturnsboolTrue if point is inside the polygon.
ComplexityO(n)

polygon_area_numpy()

polygon_area_numpy(polygon: numpy.NDArray) -> float

Get the area of a polygon from numpy array.

ParameterTypeDescription
polygonnumpy.NDArrayPolygon as a 2D numpy array.
ReturnsfloatSigned area.
ComplexityO(n)

polygon_bounds_numpy()

polygon_bounds_numpy(polygon: numpy.NDArray) -> types.Rect

Get bounds of a polygon from numpy array.

ParameterTypeDescription
polygonnumpy.NDArrayPolygon as a 2D numpy array.
Returnstypes.RectBounding rectangle as (x_min, y_min, x_max, y_max).
ComplexityO(n)

polygon_group_bounds_numpy()

polygon_group_bounds_numpy(polygons: Sequence[numpy.NDArray]) -> types.Rect

Get bounds of polygon group from numpy arrays.

ParameterTypeDescription
polygonsSequence[numpy.NDArray]Sequence of 2D numpy arrays.
Returnstypes.RectBounding rectangle as (x_min, y_min, x_max, y_max).
ComplexityO(n * m)

polygon_perimeter_numpy()

polygon_perimeter_numpy(polygon: numpy.NDArray) -> float

Get the perimeter of a polygon from numpy array.

ParameterTypeDescription
polygonnumpy.NDArrayPolygon as a 2D numpy array.
ReturnsfloatPerimeter length.
ComplexityO(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.

ParameterTypeDescription
poly1numpy.NDArrayFirst polygon as a 2D numpy array.
poly2numpy.NDArraySecond polygon as a 2D numpy array.
min_areafloat = 0Minimum intersection area threshold.
ReturnsboolTrue if polygons intersect.
ComplexityO(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).

ParameterTypeDescription
polygonSequence[tuple[float, float]]Polygon as (x, y) points.
spacingfloatMaximum allowed segment length.
Returnslist[tuple[float, float]]Resampled polygon as list of (x, y) points.
ComplexityO(n * m)

rotate_polygon()

rotate_polygon(polygon: Sequence[types.Point], angle: float) -> types.Polygon

Rotate a polygon by an angle.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
anglefloatRotation angle in degrees.
Returnstypes.PolygonRotated polygon.
ComplexityO(n)

rotate_polygon_numpy()

rotate_polygon_numpy(polygon: numpy.NDArray, angle: float) -> numpy.NDArray

Rotate a polygon from numpy array.

ParameterTypeDescription
polygonnumpy.NDArrayPolygon as a 2D numpy array.
anglefloatRotation angle in degrees.
Returnsnumpy.NDArrayRotated polygon as numpy array.
ComplexityO(n)

rotate_polygons()

rotate_polygons(
polygons: Sequence[types.Polygon],
angle: float,
) -> list[types.Polygon]

Rotate multiple polygons by an angle.

ParameterTypeDescription
polygonsSequence[types.Polygon]List of polygons to rotate.
anglefloatRotation angle in degrees.
Returnslist[types.Polygon]Rotated polygons.
ComplexityO(n * m)

rotate_polygons_numpy()

rotate_polygons_numpy(
polygons: Sequence[numpy.NDArray],
angle: float,
) -> list[numpy.NDArray]

Rotate polygons from numpy arrays.

ParameterTypeDescription
polygonsSequence[numpy.NDArray]Sequence of 2D numpy arrays.
anglefloatRotation angle in degrees.
Returnslist[numpy.NDArray]List of rotated numpy arrays.
ComplexityO(n * m)

scale_polygon()

scale_polygon(
polygon: Sequence[types.Point],
scale: float,
scale_y: Optional[float] = None,
) -> types.Polygon

Scale a polygon.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
scalefloatX (and Y if scale_y is None) scale factor.
scale_yOptional[float] = NoneY scale factor (optional).
Returnstypes.PolygonScaled polygon.
ComplexityO(n)

to_clipper_numpy()

to_clipper_numpy(polygon: Sequence[numpy.NDArray]) -> list[tuple[int, int]]

Convert a numpy polygon to Clipper integer coordinates.

ParameterTypeDescription
polygonSequence[numpy.NDArray]Sequence of 2D numpy arrays.
Returnslist[tuple[int, int]]List of (x, y) integer tuples.
ComplexityO(n * m)

translate_bounds()

translate_bounds(bounds: types.Rect, dx: float, dy: float) -> types.Rect

Translate a bounding rectangle.

ParameterTypeDescription
boundstypes.RectBounding rectangle (x_min, y_min, x_max, y_max).
dxfloatX translation.
dyfloatY translation.
Returnstypes.RectTranslated bounding rectangle.
ComplexityO(1)

translate_polygon()

translate_polygon(
polygon: Sequence[types.Point],
dx: float,
dy: float,
) -> types.Polygon

Translate a polygon.

ParameterTypeDescription
polygonSequence[types.Point]Polygon as (x, y) points.
dxfloatX translation.
dyfloatY translation.
Returnstypes.PolygonTranslated polygon.
ComplexityO(n)

translate_polygon_numpy()

translate_polygon_numpy(
polygon: numpy.NDArray,
dx: float,
dy: float,
) -> numpy.NDArray

Translate a polygon from numpy array.

ParameterTypeDescription
polygonnumpy.NDArrayPolygon as a 2D numpy array.
dxfloatX translation.
dyfloatY translation.
Returnsnumpy.NDArrayTranslated polygon as numpy array.
ComplexityO(n)

translate_polygons()

translate_polygons(
polygons: Sequence[types.Polygon],
dx: float,
dy: float,
) -> list[types.Polygon]

Translate a list of polygons.

ParameterTypeDescription
polygonsSequence[types.Polygon]List of polygons to translate.
dxfloatX translation.
dyfloatY translation.
Returnslist[types.Polygon]Translated polygons.
ComplexityO(n * m)

translate_polygons_numpy()

translate_polygons_numpy(
polygons: Sequence[numpy.NDArray],
dx: float,
dy: float,
) -> list[numpy.NDArray]

Translate polygons from numpy arrays.

ParameterTypeDescription
polygonsSequence[numpy.NDArray]Sequence of 2D numpy arrays.
dxfloatX translation.
dyfloatY translation.
Returnslist[numpy.NDArray]List of translated numpy arrays.
ComplexityO(n * m)

walk_polygon_from_point()

walk_polygon_from_point(
polygon: list[tuple[float, float]],
start: tuple[float, float],
) -> list[tuple[int, float, float]]
ParameterTypeDescription
polygonlist[tuple[float, float]]
starttuple[float, float]
Returnslist[tuple[int, float, float]]

 returns vertices in walk order starting from the vertex closest to a marker.

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]]
ParameterTypeDescription
polygonlist[tuple[float, float]]
start_idxint
forwardbool
Returnslist[tuple[int, float, float]]