batgrl.geometry.motion#
A module for constant motion along a bezier curve.
Functions
|
Move has_pos along a path of Bezier curves at some speed (in cells per second). |
Classes
|
A Bezier curve. |
|
An object with a |
|
An object with a |
- class batgrl.geometry.motion.BezierCurve(control_points: ndarray[tuple[int, Literal[2]], dtype[float64]], arc_length_approximation: int = 50)#
Bases:
object
A Bezier curve.
- Parameters:
- control_pointsCoords
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_length
floatApproximate length of Bezier curve.
- arc_length_approximationint
Number of evaluations for arc length approximation.
- arc_lengthsFloat1D
Approximate arc lengths along Bezier curve.
- coefFloat1D
Binomial coefficients of Bezier curve.
- control_pointsCoords
Array of control points of Bezier curve with shape (N, 2).
degree
intDegree 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[tuple[Literal[2]] | tuple[Literal[1], Literal[2]], dtype[float64]] #
Evaluate the Bezier curve at a proportion of its total arc length.
- control_points: ndarray[tuple[int, Literal[2]], dtype[float64]]#
Array of control points of Bezier curve with shape (N, 2).
- property degree: int#
Degree of Bezier curve.
- evaluate(t: float) ndarray[tuple[Literal[2]] | tuple[Literal[1], Literal[2]], dtype[float64]] #
- evaluate(t: ndarray[tuple[int, Literal[2]], dtype[float64]]) ndarray[tuple[int, Literal[2]], dtype[float64]]
Evaluate the Bezier curve at t (0 <= t <= 1).
- class batgrl.geometry.motion.HasPosAttr(*args, **kwargs)#
Bases:
Protocol
An object with a
pos
attribute.- pos: Coord#
- class batgrl.geometry.motion.HasPosProp(*args, **kwargs)#
Bases:
Protocol
An object with a
pos
property.- Attributes:
- pos
- property pos: Coord#
- 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.