layerview.visualization.point_cloud.interpolation module

Toolpath interpolation tools.

class layerview.visualization.point_cloud.interpolation.CircularArcInterpolator[source]

Bases: Interpolator

Circular arc move interpolator.

_MAX_ERROR_DEFAULT: float = 0.1
_abc_impl = <_abc_data object>
classmethod _get_angle_abs(src: LPoint2d, dst: LPoint2d, pivot: LPoint2d, is_clockwise: bool)[source]

Return absolute rotation angle from src to dst, around pivot.

Takes rotation direction (clockwise, counterclockwise) into account.

Parameters:
  • src (Point2D) –

  • dst (Point2D) –

  • pivot (Point2D) –

  • is_clockwise (bool) –

Returns:

angle_abs – Rotation angle from source to destination, around pivot in the specified direction (clockwise, counterclockwise).

Return type:

float

classmethod _get_angle_step(radius: float, max_error: float, is_clockwise: bool) float[source]

Return rotation angle step, based on specified constraints.

Rotation by the calculated angle step results in at most max_error absolute interpolation error.

Parameters:
  • radius (float) – Arc radius.

  • max_error (float) – Maximum allowed absolute error.

  • is_clockwise (bool) – If True, the rotation is treated as clockwise. Otherwise, the rotation is treated as counterclockwise.

Returns:

Angle step.

Return type:

float

classmethod _get_radius(point_on_arc: LPoint2d, pivot: LPoint2d) float[source]

Calc arc radius, based on point on arc and pivot.

Parameters:
  • point_on_arc (Point2D) – Point on arc.

  • pivot (Point2D) – Rotation pivot, aka arc center.

Returns:

Radius of the arc.

Return type:

float

classmethod interpolate(src: LPoint2d, dst: LPoint2d, pivot: LPoint2d, is_clockwise: bool, max_err: float = 0.1, *args, **kwargs) List[LPoint2d][source]

Interpolate circular arc from src to dst.

Expects both src and dst to be equidistant from pivot.

Parameters:
  • src (Point2D) – Source point.

  • dst (Point2D) – Destination point.

  • pivot (Point2D) – Pivot point. Arc’s circle center point.

  • is_clockwise (bool) – Defines whether the arc is clockwise or counterclockwise.

  • max_err (float) – Max allowed distance between arc chord and radius.

Returns:

Interpolated points. Includes source and destination points.

Return type:

List[Point2D]

Raises:

ValueError – If src and dst points are not equidistant from pivot.

class layerview.visualization.point_cloud.interpolation.Interpolator[source]

Bases: ABC

Generic toolpath interpolator.

_abc_impl = <_abc_data object>
abstract classmethod interpolate(src: LPoint2d, dst: LPoint2d, *args, **kwargs) List[LPoint2d][source]

Interpolate move from src to dst.

Parameters:
  • src (Point2D) – Source point.

  • dst (Point2D) – Destination point.

  • *args

  • **kwargs

Returns:

List of intermediate, interpolated points, between source and destination.

Return type:

List[Point2D]