template<UnsignedInt order, UnsignedInt dimensions, class T>
Magnum::Math::Bezier class

Bézier curve.

Template parameters
order Order of Bézier curve
dimensions Dimensions of control points
T Underlying data type

Represents a M-order N-dimensional Bézier Curve segment.

Cubic Bézier curves are fully interchangeable with cubic Hermite splines, use fromCubicHermite() and CubicHermite::fromBezier() for the conversion.

Public types

enum (anonymous): UnsignedInt { Order = order, Dimensions = dimensions }
using Type = T
Underlying data type.

Public static functions

template<class VectorType>
static auto fromCubicHermite(const CubicHermite<VectorType>& a, const CubicHermite<VectorType>& b) -> Bezier<order, dimensions, T>
Create cubic Hermite spline point from adjacent Bézier curve segments.

Constructors, destructors, conversion operators

Bezier() constexpr noexcept
Default constructor.
Bezier(ZeroInitT) explicit constexpr noexcept
Construct a zero curve.
Bezier(Magnum::NoInitT) explicit noexcept
Construct a Bézier without initializing the contents.
template<typename... U>
Bezier(const Vector<dimensions, T>& first, U... next) constexpr noexcept
Construct a Bézier curve with given array of control points.
template<class U>
Bezier(const Bezier<order, dimensions, U>& other) explicit constexpr noexcept
Construct a Bézier curve from another of different type.
template<class U, class = decltype(Implementation::BezierConverter<order, dimensions, T, U>::from(std::declval<U>()))>
Bezier(const U& other) explicit constexpr noexcept
Construct a Bézier curve from external representation.
template<class U, class = decltype(Implementation::BezierConverter<order, dimensions, T, U>::to(std::declval<Bezier<order, dimensions, T>>()))>
operator U() const explicit constexpr
Convert the Bézier curve to external representation.

Public functions

auto data() -> Vector<dimensions, T>*
Raw data.
auto data() const -> const Vector<dimensions, T>* constexpr
auto operator==(const Bezier<order, dimensions, T>& other) const -> bool
Equality comparison.
auto operator!=(const Bezier<order, dimensions, T>& other) const -> bool
Non-equality comparison.
auto operator[](std::size_t i) -> Vector<dimensions, T>&
Control point access.
auto operator[](std::size_t i) const -> const Vector<dimensions, T>& constexpr
auto value(T t) const -> Vector<dimensions, T>
Interpolate the curve at given position.
auto subdivide(T t) const -> Containers::Pair<Bezier<order, dimensions, T>, Bezier<order, dimensions, T>>
Subdivide the curve at given position.

Enum documentation

template<UnsignedInt order, UnsignedInt dimensions, class T>
enum Magnum::Math::Bezier<order, dimensions, T>::(anonymous): UnsignedInt

Enumerators
Order

Order of Bézier curve

Dimensions

Dimensions of control points

Function documentation

template<UnsignedInt order, UnsignedInt dimensions, class T> template<class VectorType>
static Bezier<order, dimensions, T> Magnum::Math::Bezier<order, dimensions, T>::fromCubicHermite(const CubicHermite<VectorType>& a, const CubicHermite<VectorType>& b)

Create cubic Hermite spline point from adjacent Bézier curve segments.

Given two cubic Hermite spline points defined by points $ \boldsymbol{p}_i $ , in-tangents $ \boldsymbol{m}_i $ and out-tangents $ \boldsymbol{n}_i $ , the corresponding cubic Bezier curve segment with points $ \boldsymbol{c}_0 $ , $ \boldsymbol{c}_1 $ , $ \boldsymbol{c}_2 $ and $ \boldsymbol{c}_3 $ is defined as:

\[ \begin{array}{rcl} \boldsymbol{c}_0 & = & \boldsymbol{p}_a \\ \boldsymbol{c}_1 & = & \frac{1}{3} \boldsymbol{n}_a - \boldsymbol{p}_a \\ \boldsymbol{c}_2 & = & \boldsymbol{p}_b - \frac{1}{3} \boldsymbol{m}_b \\ \boldsymbol{c}_3 & = & \boldsymbol{p}_b \end{array} \]

Enabled only on CubicBezier for CubicHermite with vector underlying types. See CubicHermite::fromBezier() for the inverse operation.

template<UnsignedInt order, UnsignedInt dimensions, class T>
Magnum::Math::Bezier<order, dimensions, T>::Bezier() constexpr noexcept

Default constructor.

Equivalent to Bezier(ZeroInitT).

template<UnsignedInt order, UnsignedInt dimensions, class T>
Magnum::Math::Bezier<order, dimensions, T>::Bezier(ZeroInitT) explicit constexpr noexcept

Construct a zero curve.

All control points are zero vectors.

template<UnsignedInt order, UnsignedInt dimensions, class T> template<class U>
Magnum::Math::Bezier<order, dimensions, T>::Bezier(const Bezier<order, dimensions, U>& other) explicit constexpr noexcept

Construct a Bézier curve from another of different type.

Performs only default casting on the values, no rounding or anything else.

template<UnsignedInt order, UnsignedInt dimensions, class T>
Vector<dimensions, T>* Magnum::Math::Bezier<order, dimensions, T>::data()

Raw data.

Contrary to what Doxygen shows, returns reference to an one-dimensional fixed-size array of order + 1 elements, i.e. T(&)[size].

template<UnsignedInt order, UnsignedInt dimensions, class T>
const Vector<dimensions, T>* Magnum::Math::Bezier<order, dimensions, T>::data() const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<UnsignedInt order, UnsignedInt dimensions, class T>
Vector<dimensions, T>& Magnum::Math::Bezier<order, dimensions, T>::operator[](std::size_t i)

Control point access.

i should not be larger than Order.

template<UnsignedInt order, UnsignedInt dimensions, class T>
const Vector<dimensions, T>& Magnum::Math::Bezier<order, dimensions, T>::operator[](std::size_t i) const constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<UnsignedInt order, UnsignedInt dimensions, class T>
Vector<dimensions, T> Magnum::Math::Bezier<order, dimensions, T>::value(T t) const

Interpolate the curve at given position.

Returns point on the curve for given interpolation factor. Uses the De Casteljau's algorithm.

template<UnsignedInt order, UnsignedInt dimensions, class T>
Containers::Pair<Bezier<order, dimensions, T>, Bezier<order, dimensions, T>> Magnum::Math::Bezier<order, dimensions, T>::subdivide(T t) const

Subdivide the curve at given position.

Returns two Bézier curves following the original curve, split at given interpolation factor. Uses the De Casteljau's algorithm.

template<UnsignedInt order, UnsignedInt dimensions, class T> template<UnsignedInt order, UnsignedInt dimensions, class T>
Utility::Debug& operator<<(Debug& debug, const Bezier<order, dimensions, T>& value)

Debug output operator.