跳转到主要内容

raygeo.geo.algo.fillet

Pure-geometry fillet operations.

Domain-neutral utilities for creating circular fillet arcs, appending them to polylines, and trimming to safe spans.

  • create_fillet_polyline — circular arc tangent to a direction.
  • append_end_fillets — fillet both ends of an open polyline.
  • trim_to_safe_fillet_span — longest sub-span whose end fillets avoid obstacles.

Functions

append_end_fillets()

append_end_fillets(
polyline: Sequence[tuple[float, float]],
radius: float,
sweep_angle: float,
side: float,
) -> list[tuple[float, float]]

Append fillet arcs to both ends of an open polyline.

A reversed fillet is added at the start and a forward fillet at the end, producing a smooth rounded path.

ParameterTypeDescription
polylineSequence[tuple[float, float]]Input open polyline.
radiusfloatFillet radius.
sweep_anglefloatArc sweep angle in radians.
sidefloatOffset side (+1 left, -1 right).
Returnslist[tuple[float, float]]Full polyline with fillets.

append_end_fillets rounds both ends of an open polyline with reversed-start / forward-end fillet arcs

append_end_fillets rounds both ends of an open polyline with reversed-start / forward-end fillet arcs

create_fillet_polyline()

create_fillet_polyline(
p: tuple[float, float],
dir: tuple[float, float],
radius: float,
sweep_angle: float,
side: float,
reverse: bool,
) -> tuple[tuple[float, float], list[tuple[float, float]]]

Create a circular fillet arc tangent to dir at p.

side selects the offset side (+1 = left of dir, -1 = right). When reverse is True the arc curls back opposite to dir.

ParameterTypeDescription
ptuple[float, float]Start point (x, y).
dirtuple[float, float]Tangent direction vector (dx, dy).
radiusfloatFillet radius.
sweep_anglefloatArc sweep angle in radians.
sidefloatOffset side (+1 left, -1 right).
reverseboolWhether the arc is reversed.
Returnstuple[tuple[float, float], list[tuple[float, float]]](center, polyline) — arc centre and fillet vertices.

create_fillet_polyline generates circular fillet arcs of arbitrary sweep angle, tangent to a direction at a point

create_fillet_polyline generates circular fillet arcs of arbitrary sweep angle, tangent to a direction at a point

create_fillet_polyline with side=+1 (left) and side=-1 (right) of the direction vector

create_fillet_polyline with side=+1 (left) and side=-1 (right) of the direction vector

fillet_arc_ends()

fillet_arc_ends(
arc: Sequence[tuple[float, float]],
pocket_boundary: Sequence[tuple[float, float]],
islands: Sequence[Sequence[tuple[float, float]]] = [],
tool_radius: float = 3,
wall_margin: float = 0,
) -> list[tuple[float, float]]

Round both ends of a cutting arc with quarter-circle fillets.

The arc is trimmed to the longest sub-arc whose tool sweep (arc + end fillets of tool_radius) does not collide with pocket_boundary or islands. A 90° fillet of tool_radius is then appended at each end.

ParameterTypeDescription
arcSequence[tuple[float, float]]Cutting arc vertices (open polyline).
pocket_boundarySequence[tuple[float, float]]Outer boundary of the pocket.
islandsSequence[Sequence[tuple[float, float]]] = []List of island (hole) polygons (default []).
tool_radiusfloat = 3Tool / fillet radius in mm (default 3.0).
wall_marginfloat = 0Extra clearance past tangency (default 0.0).
Returnslist[tuple[float, float]]Filleted arc as an open polyline.

fillet_arc_ends trims the arc to the longest safe sub-arc and appends quarter-circle fillets at each end

fillet_arc_ends trims the arc to the longest safe sub-arc and appends quarter-circle fillets at each end

find_safe_sweep_end()

find_safe_sweep_end(
arc: Sequence[tuple[float, float]],
pocket_boundary: Sequence[tuple[float, float]],
islands: Sequence[Sequence[tuple[float, float]]] = [],
tool_radius: float = 3,
wall_margin: float = 0,
) -> tuple[tuple[float, float], tuple[float, float]] | None

Find the longest safe sub-arc by iterative sweep shortening.

Returns the two points (enter, exit) delimiting the longest sub-arc of arc whose tool sweep (arc + end fillets of tool_radius) does not collide with pocket_boundary or islands. Shortens from each end until the sweep is clear. Returns None when no usable safe sub-arc remains.

ParameterTypeDescription
arcSequence[tuple[float, float]]Cutting arc vertices (open polyline).
pocket_boundarySequence[tuple[float, float]]Outer boundary of the pocket.
islandsSequence[Sequence[tuple[float, float]]] = []List of island (hole) polygons (default []).
tool_radiusfloat = 3Tool radius in mm (default 3.0).
wall_marginfloat = 0Extra clearance past tangency (default 0.0).
Returnstuple[tuple[float, float], tuple[float, float]] | None

find_safe_sweep_end returns the (enter, exit) points delimiting the longest sub-arc whose tool sweep avoids islands

find_safe_sweep_end returns the (enter, exit) points delimiting the longest sub-arc whose tool sweep avoids islands

trim_to_safe_fillet_span()

trim_to_safe_fillet_span(
polyline: Sequence[tuple[float, float]],
outer_boundary: Sequence[tuple[float, float]],
inner_obstacles: Sequence[Sequence[tuple[float, float]]] = [],
radius: float = 3,
margin: float = 0,
) -> tuple[tuple[float, float], tuple[float, float]] | None

Find the longest sub-span whose end fillets avoid obstacles.

Shortens from each end until the sweep is clear. Returns (enter, exit) or None.

ParameterTypeDescription
polylineSequence[tuple[float, float]]Open polyline to trim.
outer_boundarySequence[tuple[float, float]]Outer boundary polygon.
inner_obstaclesSequence[Sequence[tuple[float, float]]] = []List of obstacle polygons (default []).
radiusfloat = 3Fillet radius (default 3.0).
marginfloat = 0Extra clearance past tangency (default 0.0).
Returnstuple[tuple[float, float], tuple[float, float]] | None

trim_to_safe_fillet_span finds the longest sub-span whose end fillets do not collide with obstacles (red)

trim_to_safe_fillet_span finds the longest sub-span whose end fillets do not collide with obstacles (red)