RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
rz::CubicBezier Class Reference

Cubic Bézier parametric path segment. More...

#include <CubicBezier.hpp>

Inheritance diagram for rz::CubicBezier:
rz::ParametricPath

Classes

class  Knot
 Control knot defining both position and tangent handle geometry. More...

Public Member Functions

 CubicBezier (const Knot &start, const Knot &end) noexcept
 Constructs a cubic Bézier segment between two control knots.
Point getPoint (double t) const noexcept override
 Computes the position P(t) along the cubic Bézier.
Point getVelocity (double t) const noexcept override
 Computes the first derivative dP/dt at parameter t.
Point getAcceleration (double t) const noexcept override
 Computes the second derivative d²P/dt² at parameter t.
Public Member Functions inherited from rz::ParametricPath
virtual ~ParametricPath ()=default
 Virtual destructor.
virtual Angle getTheta (double t) const noexcept
 Path heading: orientation of the tangent dP/dt.
virtual Curvature getCurvature (double t) const noexcept
 Signed curvature κ(t) = wedge(dP/dt, d²P/dt²) / |dP/dt|³.
virtual Length getLength (double tStart=0, double tEnd=1) const noexcept
 Arclength along the path between parameters tStart and tEnd.
virtual double stepT (double t, Length distance) const noexcept
 Advance the parameter by a target arclength measured along the path.
virtual DiscretePath toDiscrete (Length distance, bool includeEnd=true) const

Detailed Description

Cubic Bézier parametric path segment.

A CubicBezier represents a smooth parametric curve defined by four control points: P(t) = (1-t)^3 c_0 + 3(1-t)^2 t c_1 + 3(1-t)t^2 c_2 + t^3 c_3.

Each segment is constructed from two knots, which encode both position and tangent direction/length at their endpoints. The constructor expands those into the four cubic control points:

  • c₀ = start.getPoint()
  • c₁ = start.getForwardControl()
  • c₂ = end.getBackwardControl()
  • c₃ = end.getPoint()

Continuity: When consecutive segments share the same end/start Knot, the resulting chain is automatically C⁰ and C¹ continuous at the join.

See also
PiecewiseCubicBezier

Constructor & Destructor Documentation

◆ CubicBezier()

rz::CubicBezier::CubicBezier ( const Knot & start,
const Knot & end )
noexcept

Constructs a cubic Bézier segment between two control knots.

The start and end control points define the endpoints and tangents. Internally, the four Bézier control points are expanded as:

c0 = start.getPoint();
c1 = start.getForwardControl();
c2 = end.getBackwardControl();
c3 = end.getPoint();
void start(RobotConfig config)
Starts RaidZeroLib on the brain. Call once from initialize().
Parameters
startStart control knot.
endEnd control knot.

Member Function Documentation

◆ getAcceleration()

Point rz::CubicBezier::getAcceleration ( double t) const
overridevirtualnoexcept

Computes the second derivative d²P/dt² at parameter t.

P''(t) = 6(1-t)(c_2 - 2c_1 + c_0) + 6t(c_3 - 2c_2 + c_1)

Parameters
tNormalized parameter ∈ [0, 1].
Returns
Acceleration vector (meters per unit t²).

Implements rz::ParametricPath.

◆ getPoint()

Point rz::CubicBezier::getPoint ( double t) const
overridevirtualnoexcept

Computes the position P(t) along the cubic Bézier.

Parameters
tNormalized parameter ∈ [0, 1].
Returns
2D point (meters).

Implements rz::ParametricPath.

◆ getVelocity()

Point rz::CubicBezier::getVelocity ( double t) const
overridevirtualnoexcept

Computes the first derivative dP/dt at parameter t.

P'(t) = 3(1-t)^2 (c_1 - c_0) + 6(1-t)t (c_2 - c_1) + 3t^2 (c_3 - c_2)

Parameters
tNormalized parameter ∈ [0, 1].
Returns
Velocity vector (meters per unit t).

Implements rz::ParametricPath.


The documentation for this class was generated from the following file: