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.
using VectorType = Implementation::BezierTraits<dimensions, T>::Type new in Git master
Underlying vector type.

Public static functions

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 VectorType& 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() -> VectorType*
Raw data.
auto data() const -> const VectorType* 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) -> VectorType&
Control point access.
auto operator[](std::size_t i) const -> const VectorType& constexpr
auto value(T t) const -> VectorType
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

Typedef documentation

template<UnsignedInt order, UnsignedInt dimensions, class T>
typedef Implementation::BezierTraits<dimensions, T>::Type Magnum::Math::Bezier<order, dimensions, T>::VectorType new in Git master

Underlying vector type.

T in 1D, Vector2<T> in 2D, Vector3<T> in 3D.

Function documentation

template<UnsignedInt order, UnsignedInt dimensions, class T>
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>
VectorType* 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 VectorType* 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>
VectorType& 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 VectorType& 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>
VectorType 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.