跳转到主要内容

raygeo.ops.cut.interp

Interpolation

Bracket of error values for adaptive-stepping interpolation.

Maintains a min/max bracket around the target cut-area per distance and linearly interpolates to find the steering angle that achieves it.

add()

add(
error: float,
angle: float,
pos: tuple[float, float],
allow_skip: bool,
is_conventional: bool,
) -> None

Add a new sample to the bracket.

Maintains the invariant min.error <= max.error and keeps samples closest to zero on each side of the root.

ParameterTypeDescription
errorfloat
anglefloat
postuple[float, float]
allow_skipbool
is_conventionalbool
ReturnsNone

clamp_angle()

clamp_angle(angle: float, max_deflection: float) -> float

Clamp angle to ±max_deflection.

ParameterTypeDescription
anglefloat
max_deflectionfloat
Returnsfloat

has_pos()

has_pos(pos: tuple[float, float]) -> bool

Whether either endpoint was sampled at pos.

ParameterTypeDescription
postuple[float, float]
Returnsbool

interpolate()

interpolate() -> float

Linearly interpolate between min and max to find the angle where error = 0, clamped to [0.2, 0.8] in parameter space.

ParameterTypeDescription
Returnsfloat

Interpolation bracket showing error vs steering angle. The red and green markers are the min and max bracket samples; the purple dashed line marks the interpolated zero-crossing angle.

Interpolation bracket showing error vs steering angle. The red and green markers are the min and max bracket samples; the purple dashed line marks the interpolated zero-crossing angle.

joint_is_valid()

joint_is_valid() -> bool

Whether a valid bracket around the root exists (min.error < 0 <= max.error).

ParameterTypeDescription
Returnsbool

max_angle()

max_angle() -> float

Maximum steering angle: +π/4.

ParameterTypeDescription
Returnsfloat

min_angle()

min_angle() -> float

Minimum steering angle: -π/4.

ParameterTypeDescription
Returnsfloat

Functions

point_in_valid_area()

point_in_valid_area(
pt: tuple[float, float],
area: Sequence[Sequence[tuple[float, float]]],
) -> bool

Check whether pt lies in a valid tool area defined by polygon shells and holes.

CCW-wound polygons are outer shells; CW-wound polygons are holes. A point is valid iff it is inside at least one CCW polygon AND outside all CW polygons.

ParameterTypeDescription
pttuple[float, float]Query point (x, y).
areaSequence[Sequence[tuple[float, float]]]List of polygon rings (each a list of (x, y) tuples).
ReturnsboolTrue if the point is in a valid region.

Valid-area polygon with a CCW shell (blue) and CW hole (red dashed). Points are marked green (valid) or red (invalid) based on :func:.

Valid-area polygon with a CCW shell (blue) and CW hole (red dashed). Points are marked green (valid) or red (invalid) based on :func:~raygeo.ops.cut.interp.point_in_valid_area.

rotate()

rotate(v: tuple[float, float], angle: float) -> tuple[float, float]

Rotate a 2D vector by angle radians.

ParameterTypeDescription
vtuple[float, float]Vector (x, y).
anglefloatRotation angle in radians.
Returnstuple[float, float]Rotated vector (x', y').

Rotation of a unit vector  by various angles using :func:.

Rotation of a unit vector (1, 0) by various angles using :func:~raygeo.ops.cut.interp.rotate.