batgrl.geometry.motion#

A module for constant motion along a bezier curve.

Functions

move_along_path(has_pos, path, *[, speed, ...])

Move has_pos along a path of Bezier curves at some speed (in cells per second).

Classes

BezierCurve(control_points[, ...])

A Bezier curve.

HasPos(*args, **kwargs)

An object with a position.

class batgrl.geometry.motion.BezierCurve(control_points: ndarray[Any, dtype[float32]], arc_length_approximation: int = 50)#

Bases: object

A Bezier curve.

Parameters:
control_pointsNDArray[np.float32]

Array of control points of Bezier curve with shape (N, 2).

arc_length_approximationint, default: 50

Number of evaluations for arc length approximation.

Attributes:
arc_lengthfloat

Approximate length of Bezier curve.

arc_length_approximationint

Number of evaluations for arc length approximation.

arc_lengthsNDArray[np.float32]

Approximate arc lengths along Bezier curve.

coefNDArray[np.float32]

Binomial coefficients of Bezier curve.

control_pointsNDArray[np.float32]

Array of control points of Bezier curve with shape (N, 2).

degreeint

Degree of Bezier curve.

Methods

evaluate(t)

Evaluate the Bezier curve at t (0 <= t <= 1).

arc_length_proportion(p)

Evaluate the Bezier curve at a proportion of its total arc length.

property arc_length: float#

Approximate length of Bezier curve.

arc_length_approximation: int = 50#

Number of evaluations for arc length approximation.

arc_length_proportion(p: float) ndarray[Any, dtype[float32]]#

Evaluate the Bezier curve at a proportion of its total arc length.

control_points: ndarray[Any, dtype[float32]]#

Array of control points of Bezier curve with shape (N, 2).

property degree: int#

Degree of Bezier curve.

evaluate(t: float | ndarray[Any, dtype[float32]]) ndarray[Any, dtype[float32]]#

Evaluate the Bezier curve at t (0 <= t <= 1).

class batgrl.geometry.motion.HasPos(*args, **kwargs)#

Bases: Protocol

An object with a position.

pos: Point#
async batgrl.geometry.motion.move_along_path(has_pos: HasPos, path: list[BezierCurve], *, speed: float = 1.0, easing: Literal['linear', 'in_quad', 'out_quad', 'in_out_quad', 'in_cubic', 'out_cubic', 'in_out_cubic', 'in_quart', 'out_quart', 'in_out_quart', 'in_quint', 'out_quint', 'in_out_quint', 'in_sine', 'out_sine', 'in_out_sine', 'in_exp', 'out_exp', 'in_out_exp', 'in_circ', 'out_circ', 'in_out_circ', 'in_elastic', 'out_elastic', 'in_out_elastic', 'in_back', 'out_back', 'in_out_back', 'in_bounce', 'out_bounce', 'in_out_bounce'] = 'linear', on_start: Callable[[], None] | None = None, on_progress: Callable[[float], None] | None = None, on_complete: Callable[[], None] | None = None)#

Move has_pos along a path of Bezier curves at some speed (in cells per second).

Parameters:
has_posHasPos

Object to be moved along path.

pathlist[BezierCurve]

A path made up of Bezier curves.

speedfloat, default: 1.0

Speed of movement in approximately cells per second.

on_startCallable[[], None] | None, default: None

Called when motion starts.

on_progressCallable[[float], None] | None, default: None

Called as motion updates with current progress.

on_completeCallable[[], None] | None, default: None

Called when motion completes.