Zum Hauptinhalt springen

raygeo.geo.algo.medial_axis

Medial axis of a rectangular pocket — skeleton from center to corners.

Medial axis of a rectangular pocket — skeleton from center to corners. Medial Axis Transform (MAT) computation.

The MAT is the skeleton of a 2D domain — the set of points equidistant to two or more boundary features. It is computed via Delaunay-circumcenter extraction from a constrained triangulation of the pocket boundary.

  • compute_medial_axis — compute the MAT of a pocket (with optional islands).

Functions

compute_medial_axis()

compute_medial_axis(
outer: Sequence[tuple[float, float]],
holes: Sequence[Sequence[tuple[float, float]]] = [],
tool_radius: float = 1,
sampling_spacing: float = 1,
) -> tuple[list[tuple[float, float]], list[float], list[tuple[int, int]], int, list[list[int]]]

Compute the Medial Axis Transform of a planar domain.

Returns (nodes, clearances, edges, root, branches).

* **nodes** — `list[(x, y)]` of medial axis vertex positions.
* **clearances** — `list[float]` inscribed circle radius per node.
* **edges** — `list[(int, int)]` tree edges (parent, child).
* **root** — `int` index of the maximum-clearance node.
* **branches** — `list[list[int]]` each branch is a node-index path
from a junction to another junction or leaf.
ParameterTypeDescription
outerSequence[tuple[float, float]]Outer boundary polygon (CCW).
holesSequence[Sequence[tuple[float, float]]] = []List of hole polygons (CW). Defaults to [].
tool_radiusfloat = 1Minimum clearance; narrower branches are pruned.
sampling_spacingfloat = 1Sampling density for boundary + Steiner grid. Smaller = finer MAT.
Returnstuple[list[tuple[float, float]], list[float], list[tuple[int, int]], int, list[list[int]]](nodes, clearances, edges, root, branches) where

Medial axis with three rectangular islands — skeleton branches around each obstacle.

Medial axis with three rectangular islands — skeleton branches around each obstacle.

Medial axis of a Y-shaped channel — skeleton follows the branching topology.

Medial axis of a Y-shaped channel — skeleton follows the branching topology.

mat_path()

mat_path(
outer: Sequence[tuple[float, float]],
from_pt: tuple[float, float],
to_pt: tuple[float, float],
holes: Sequence[Sequence[tuple[float, float]]] = [],
tool_radius: float = 1,
sampling_spacing: float = 1,
) -> list[tuple[float, float]] | None

Find a path between two points using the Medial Axis.

Computes the MAT of the pocket defined by outer and holes, then finds the shortest-topology path between from_pt and to_pt along the medial axis graph.

ParameterTypeDescription
outerSequence[tuple[float, float]]Outer boundary polygon (CCW).
from_pttuple[float, float]Start point (x, y).
to_pttuple[float, float]End point (x, y).
holesSequence[Sequence[tuple[float, float]]] = []List of hole polygons (CW). Defaults to [].
tool_radiusfloat = 1Minimum clearance for MAT pruning.
sampling_spacingfloat = 1Boundary sampling density.
Returnslist[tuple[float, float]] | NoneList of (x, y) waypoints along the path, or None.

MAT path routing: a path between two points (green) along the medial axis skeleton (red). The path avoids the island by following the skeleton topology.

MAT path routing: a path between two points (green) along the medial axis skeleton (red). The path avoids the island by following the skeleton topology.