#include <Magnum/Math/Bezier.h>
template<UnsignedInt order, UnsignedInt dimensions, class T>
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::
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 Bézier without initializing the contents.
-
template<typename... U>Bezier(const Vector<dimensions, T>& first, U... next) constexpr noexcept
- Construct Bézier curve with given array of control points.
-
template<class U>Bezier(const Bezier<order, dimensions, U>& other) explicit constexpr noexcept
- Construct Bézier curve from another of different type.
-
template<class U, class V = decltype(Implementation::BezierConverter<order, dimensions, T, U>::from(std::Bezier(const U& other) explicit constexpr noexcept
declval<U>()))> - Construct Bézier curve from external representation.
-
template<class U, class V = decltype(Implementation::BezierConverter<order, dimensions, T, U>::to(std::operator U() const explicit constexpr
declval<Bezier<order, dimensions, T>>()))> - Convert 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(Float t) const -> Vector<dimensions, T>
- Interpolate the curve at given position.
-
auto subdivide(Float t) const -> std::
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 , in-tangents and out-tangents , the corresponding cubic Bezier curve segment with points , , and is defined as:
Enabled only on CubicBezier for CubicHermite with vector underlying types. See CubicHermite::
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 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(Float 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>
std:: pair<Bezier<order, dimensions, T>, Bezier<order, dimensions, T>> Magnum:: Math:: Bezier<order, dimensions, T>:: subdivide(Float 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>
Corrade:: Utility:: Debug& operator<<(Corrade:: Utility:: Debug& debug,
const Bezier<order, dimensions, T>& value)
Debug output operator.