#include <Magnum/Math/CubicHermite.h>
template<class T>
CubicHermite class
Cubic Hermite spline point.
Represents a point on a cubic Hermite spline.
Unlike Bezier, which describes a curve segment, this structure describes a spline point , with in-tangent and out-tangent . This form is more suitable for animation keyframe representation. The structure assumes the in/out tangents to be in their final form, i.e. already normalized by length of their adjacent segments.
Cubic Hermite splines are fully interchangeable with cubic Bézier curves, use fromBezier() and Bezier::
Public types
- using Type = T
- Underlying data type.
Public static functions
-
template<UnsignedInt dimensions, class U>static auto fromBezier(const CubicBezier<dimensions, U>& a, const CubicBezier<dimensions, U>& b) -> CubicHermite<T>
- Create a cubic Hermite spline point from adjacent Bézier curve segments.
Constructors, destructors, conversion operators
- CubicHermite() constexpr noexcept
- Default constructor.
- CubicHermite(ZeroInitT) explicit constexpr noexcept
- Default constructor.
-
template<class U = T, class = typename std::CubicHermite(IdentityInitT) explicit constexpr noexcept
enable_if<std:: is_constructible<U, IdentityInitT>::value>::type> - Identity constructor.
-
CubicHermite(Magnum::
NoInitT) explicit noexcept - Construct a cubic Hermite spline point without initializing its contents.
- CubicHermite(const T& inTangent, const T& point, const T& outTangent) constexpr noexcept
- Construct a cubic Hermite spline point with given control points.
-
template<class U>CubicHermite(const CubicHermite<U>& other) explicit constexpr noexcept
- Construct a cubic Hermite spline point from another of different type.
Public functions
- auto data() -> T*
- Raw data.
- auto data() const -> const T*
- auto operator==(const CubicHermite<T>& other) const -> bool
- Equality comparison.
- auto operator!=(const CubicHermite<T>& other) const -> bool
- Non-equality comparison.
- auto inTangent() -> T&
- In-tangent .
- auto inTangent() const -> const T& constexpr
- auto point() -> T&
- Point .
- auto point() const -> const T& constexpr
- auto outTangent() -> T&
- Out-tangent .
- auto outTangent() const -> const T& constexpr
Function documentation
template<class T>
template<UnsignedInt dimensions, class U>
static CubicHermite<T> Magnum:: Math:: CubicHermite<T>:: fromBezier(const CubicBezier<dimensions, U>& a,
const CubicBezier<dimensions, U>& b)
Create a cubic Hermite spline point from adjacent Bézier curve segments.
Given two adjacent cubic Bézier curve segments defined by points and , , the corresponding cubic Hermite spline point , in-tangent and out-tangent is defined as:
Expects that the two segments are adjacent (i.e., the endpoint of first segment is the start point of the second). If you need to create a cubic Hermite spline point that's at the beginning or at the end of a curve, simply pass a dummy Bézier segment that satisfies this constraint as the other parameter:
CubicBezier2D segment; auto startPoint = CubicHermite2D::fromBezier( {Vector2{}, Vector2{}, Vector2{}, segment[3]}, segment); auto endPoint = CubicHermite2D::fromBezier(segment, {segment[0], Vector2{}, Vector2{}, Vector2{}});
Enabled only on vector underlying types. See Bezier::
template<class T>
Magnum:: Math:: CubicHermite<T>:: CubicHermite() constexpr noexcept
Default constructor.
Equivalent to CubicHermite(ZeroInitT) for vector types and to CubicHermite(IdentityInitT) for complex and quaternion types.
template<class T>
Magnum:: Math:: CubicHermite<T>:: CubicHermite(ZeroInitT) explicit constexpr noexcept
Default constructor.
Construct cubic Hermite spline point with all control points being zero.
template<class T>
template<class U = T, class = typename std:: enable_if<std:: is_constructible<U, IdentityInitT>::value>::type>
Magnum:: Math:: CubicHermite<T>:: CubicHermite(IdentityInitT) explicit constexpr noexcept
Identity constructor.
The point() is constructed as identity in order to have interpolation working correctly; inTangent() and outTangent() is constructed as zero. Enabled only for complex and quaternion types.
template<class T>
Magnum:: Math:: CubicHermite<T>:: CubicHermite(const T& inTangent,
const T& point,
const T& outTangent) constexpr noexcept
Construct a cubic Hermite spline point with given control points.
Parameters | |
---|---|
inTangent | In-tangent |
point | Point |
outTangent | Out-tangent |
template<class T>
template<class U>
Magnum:: Math:: CubicHermite<T>:: CubicHermite(const CubicHermite<U>& other) explicit constexpr noexcept
Construct a cubic Hermite spline point from another of different type.
Performs only default casting on the values, no rounding or anything else.
template<class T>
T* Magnum:: Math:: CubicHermite<T>:: data()
Raw data.
Contrary to what Doxygen shows, returns reference to an one-dimensional fixed-size array of three elements, i.e. T(&)[3]
.
template<class T>
const T* Magnum:: Math:: CubicHermite<T>:: data() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
const T& Magnum:: Math:: CubicHermite<T>:: inTangent() 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<class T>
const T& Magnum:: Math:: CubicHermite<T>:: point() 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<class T>
const T& Magnum:: Math:: CubicHermite<T>:: outTangent() 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<class T>
template<class T>
Debug& operator<<(Debug& debug,
const CubicHermite<T>& value)
Debug output operator.
template<class T>
template<class T, class U>
T select(const CubicHermite<T>& a,
const CubicHermite<T>& b,
U t)
Constant interpolation of two cubic Hermite spline points.
Parameters | |
---|---|
a | First spline point |
b | Second spline point |
t | Interpolation phase (from range ) |
Given segment points , in-tangents and out-tangents , the interpolated value at phase is:
Equivalent to calling select(const T&, const T&, U) on CubicHermite::a
and b
.
template<class T>
template<class T, class U>
T lerp(const CubicHermite<T>& a,
const CubicHermite<T>& b,
U t)
Linear interpolation of two cubic Hermite points.
Parameters | |
---|---|
a | First spline point |
b | Second spline point |
t | Interpolation phase (from range ) |
Given segment points , in-tangents and out-tangents , the interpolated value at phase is:
Equivalent to calling lerp(const T&, const T&, U) on CubicHermite::a
and b
.
template<class T>
template<class T>
Complex<T> lerp(const CubicHermiteComplex<T>& a,
const CubicHermiteComplex<T>& b,
T t)
Linear interpolation of two cubic Hermite complex numbers.
Equivalent to calling lerp(const Complex<T>&, const Complex<T>&, T) on CubicHermite::a
and b
. Compared to lerp(const CubicHermite<T>&, const CubicHermite<T>&, U) this adds a normalization step after. Expects that CubicHermite::a
and b
.
template<class T>
template<class T>
Quaternion<T> lerp(const CubicHermiteQuaternion<T>& a,
const CubicHermiteQuaternion<T>& b,
T t)
Linear interpolation of two cubic Hermite quaternions.
Equivalent to calling lerp(const Quaternion<T>&, const Quaternion<T>&, T) on CubicHermite::a
and b
. Compared to lerp(const CubicHermite<T>&, const CubicHermite<T>&, U) this adds a normalization step after. Expects that CubicHermite::a
and b
.
template<class T>
template<class T>
Quaternion<T> lerpShortestPath(const CubicHermiteQuaternion<T>& a,
const CubicHermiteQuaternion<T>& b,
T t)
Linear shortest-path interpolation of two cubic Hermite quaternions.
Equivalent to calling lerpShortestPath(const Quaternion<T>&, const Quaternion<T>&, T) on CubicHermite::a
and b
. Expects that CubicHermite::a
and b
.
Note that rotations interpolated with this function may go along a completely different path compared to splerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T). Use lerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T) for behavior that is consistent with spline interpolation.
template<class T>
template<class T>
Complex<T> slerp(const CubicHermiteComplex<T>& a,
const CubicHermiteComplex<T>& b,
T t)
Spherical linear interpolation of two cubic Hermite complex numbers.
Equivalent to calling slerp(const Complex<T>&, const Complex<T>&, T) on CubicHermite::a
and b
. Expects that CubicHermite::a
and b
.
template<class T>
template<class T>
Quaternion<T> slerp(const CubicHermiteQuaternion<T>& a,
const CubicHermiteQuaternion<T>& b,
T t)
Spherical linear interpolation of two cubic Hermite quaternions.
Equivalent to calling slerp(const Quaternion<T>&, const Quaternion<T>&, T) on CubicHermite::a
and b
. Expects that CubicHermite::a
and b
.
template<class T>
template<class T>
Quaternion<T> slerpShortestPath(const CubicHermiteQuaternion<T>& a,
const CubicHermiteQuaternion<T>& b,
T t)
Spherical linear shortest-path interpolation of two cubic Hermite quaternions.
Equivalent to calling slerpShortestPath(const Quaternion<T>&, const Quaternion<T>&, T) on CubicHermite::a
and b
. Expects that CubicHermite::a
and b
.
Note that rotations interpolated with this function may go along a completely different path compared to splerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T). Use slerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T) for spherical linear interpolation with behavior that is consistent with spline interpolation.
template<class T>
template<class T, class U>
T splerp(const CubicHermite<T>& a,
const CubicHermite<T>& b,
U t)
Spline interpolation of two cubic Hermite points.
Parameters | |
---|---|
a | First spline point |
b | Second spline point |
t | Interpolation phase |
Given segment points , in-tangents and out-tangents , the interpolated value at phase is:
template<class T>
template<class T>
Complex<T> splerp(const CubicHermiteComplex<T>& a,
const CubicHermiteComplex<T>& b,
T t)
Spline interpolation of two cubic Hermite complex numbers.
Unlike splerp(const CubicHermite<T>&, const CubicHermite<T>&, U) this adds a normalization step after. Given segment points , in-tangents and out-tangents , the interpolated value at phase is:
Expects that CubicHermite::a
and b
.
template<class T>
template<class T>
Quaternion<T> splerp(const CubicHermiteQuaternion<T>& a,
const CubicHermiteQuaternion<T>& b,
T t)
Spline interpolation of two cubic Hermite quaternions.
Unlike splerp(const CubicHermite<T>&, const CubicHermite<T>&, U) this adds a normalization step after. Given segment points , in-tangents and out-tangents , the interpolated value at phase is:
Expects that CubicHermite::a
and b
.