template<class T>
Magnum::Math::DualComplex class

Dual complex number.

Template parameters
T Underlying data type

Represents 2D rotation and translation. Usually denoted as the following in equations, with $ q_0 $ being the real() part and $ q_\epsilon $ the dual() part:

\[ \hat q = q_0 + \epsilon q_\epsilon \]

See Dual and Complex for further notation description and 2D and 3D transformations for brief introduction.

Base classes

template<class T>
class Dual<Complex<T>>
Dual number.

Public types

using Type = T
Underlying data type.

Public static functions

static auto rotation(Rad<T> angle) -> DualComplex<T>
Rotation dual complex number.
static auto translation(const Vector2<T>& vector) -> DualComplex<T>
Translation dual complex number.
static auto fromMatrix(const Matrix3<T>& matrix) -> DualComplex<T>
Create a dual complex number from rotation matrix.
static auto from(const Complex<T>& rotation, const Vector2<T>& translation) -> DualComplex<T> new in Git master
Create a dual complex from rotation complex and translation vector.

Constructors, destructors, conversion operators

DualComplex() constexpr noexcept
Default constructor.
DualComplex(IdentityInitT) explicit constexpr noexcept
Identity constructor.
DualComplex(ZeroInitT) explicit constexpr noexcept
Construct a zero-initialized dual complex number.
DualComplex(Magnum::NoInitT) explicit noexcept
Construct without initializing the contents.
DualComplex(const Complex<T>& real, const Complex<T>& dual = Complex<T>(T(0), T(0))) constexpr noexcept
Construct a dual complex number from real and dual part.
DualComplex(const Vector2<T>& vector) explicit constexpr noexcept
Construct a dual complex number from vector.
template<class U>
DualComplex(const DualComplex<U>& other) explicit constexpr noexcept
Construct a dual complex number from another of different type.
template<class U, class = decltype(Implementation::DualComplexConverter<T, U>::from(std::declval<U>()))>
DualComplex(const U& other) explicit constexpr
Construct a dual complex number from external representation.
DualComplex(const Dual<Complex<T>>& other) constexpr noexcept
Copy constructor.
template<class U, class = decltype(Implementation::DualComplexConverter<T, U>::to(std::declval<DualComplex<T>>()))>
operator U() const explicit constexpr
Convert the dual complex number to external representation.

Public functions

auto data() -> T*
Raw data.
auto data() const -> const T*
auto isNormalized() const -> bool
Whether the dual complex number is normalized.
auto rotation() const -> Complex<T> constexpr
Rotation part of dual complex number.
auto translation() const -> Vector2<T>
Translation part of dual complex number.
auto toMatrix() const -> Matrix3<T>
Convert dual complex number to transformation matrix.
auto operator*(const DualComplex<T>& other) const -> DualComplex<T>
Multiply with dual complex number.
auto complexConjugated() const -> DualComplex<T>
Complex-conjugated dual complex number.
auto dualConjugated() const -> DualComplex<T>
Dual-conjugated dual complex number.
auto conjugated() const -> DualComplex<T>
Conjugated dual complex number.
auto lengthSquared() const -> T
Complex number length squared.
auto length() const -> T
Dual quaternion length.
auto normalized() const -> DualComplex<T>
Normalized dual complex number (of unit length)
auto inverted() const -> DualComplex<T>
Inverted dual complex number.
auto invertedNormalized() const -> DualComplex<T>
Inverted normalized dual complex number.
auto transformVector(const Vector2<T>& vector) const -> Vector2<T> new in 2020.06
Rotate a vector with a dual complex number.
auto transformPoint(const Vector2<T>& vector) const -> Vector2<T>
Rotate and translate point with dual complex number.

Function documentation

template<class T>
static DualComplex<T> Magnum::Math::DualComplex<T>::rotation(Rad<T> angle)

Rotation dual complex number.

Parameters
angle Rotation angle (counterclockwise)
\[ \hat c = (\cos(\theta) + i \sin(\theta)) + \epsilon (0 + i0) \]

For creating a dual complex number from a rotation Complex, use the implicit conversion provided by DualComplex(const Complex<T>&, const Complex<T>&).

template<class T>
static DualComplex<T> Magnum::Math::DualComplex<T>::translation(const Vector2<T>& vector)

Translation dual complex number.

Parameters
vector Translation vector
\[ \hat c = (0 + i1) + \epsilon (v_x + iv_y) \]

template<class T>
static DualComplex<T> Magnum::Math::DualComplex<T>::fromMatrix(const Matrix3<T>& matrix)

Create a dual complex number from rotation matrix.

Expects that the matrix represents rigid transformation.

template<class T>
static DualComplex<T> Magnum::Math::DualComplex<T>::from(const Complex<T>& rotation, const Vector2<T>& translation) new in Git master

Create a dual complex from rotation complex and translation vector.

\[ \hat c = r + \epsilon (v_x + iv_y) \]

template<class T>
Magnum::Math::DualComplex<T>::DualComplex() constexpr noexcept

Default constructor.

Equivalent to DualComplex(IdentityInitT).

template<class T>
Magnum::Math::DualComplex<T>::DualComplex(IdentityInitT) explicit constexpr noexcept

Identity constructor.

Creates unit dual complex number.

\[ \hat c = (0 + i1) + \epsilon (0 + i0) \]

template<class T>
Magnum::Math::DualComplex<T>::DualComplex(const Complex<T>& real, const Complex<T>& dual = Complex<T>(T(0), T(0))) constexpr noexcept

Construct a dual complex number from real and dual part.

\[ \hat c = c_0 + \epsilon c_\epsilon \]

This constructor can be also used to implicitly convert a rotation complex number to a rotation dual complex number.

template<class T>
Magnum::Math::DualComplex<T>::DualComplex(const Vector2<T>& vector) explicit constexpr noexcept

Construct a dual complex number from vector.

To be used in transformations later.

\[ \hat c = (0 + i1) + \epsilon(v_x + iv_y) \]

template<class T> template<class U>
Magnum::Math::DualComplex<T>::DualComplex(const DualComplex<U>& other) explicit constexpr noexcept

Construct a dual complex number from another of different type.

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

template<class T>
T* Magnum::Math::DualComplex<T>::data()

Raw data.

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

template<class T>
const T* Magnum::Math::DualComplex<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>
bool Magnum::Math::DualComplex<T>::isNormalized() const

Whether the dual complex number is normalized.

Dual complex number is normalized if its real part has unit length:

\[ |c_0|^2 = |c_0| = 1 \]

template<class T>
Complex<T> Magnum::Math::DualComplex<T>::rotation() const constexpr

Rotation part of dual complex number.

template<class T>
Vector2<T> Magnum::Math::DualComplex<T>::translation() const

Translation part of dual complex number.

\[ \boldsymbol a = (c_\epsilon c_0^*) \]

template<class T>
Matrix3<T> Magnum::Math::DualComplex<T>::toMatrix() const

Convert dual complex number to transformation matrix.

template<class T>
DualComplex<T> Magnum::Math::DualComplex<T>::operator*(const DualComplex<T>& other) const

Multiply with dual complex number.

\[ \hat a \hat b = a_0 b_0 + \epsilon (a_0 b_\epsilon + a_\epsilon) \]

template<class T>
DualComplex<T> Magnum::Math::DualComplex<T>::complexConjugated() const

Complex-conjugated dual complex number.

\[ \hat c^* = c^*_0 + c^*_\epsilon \]

template<class T>
DualComplex<T> Magnum::Math::DualComplex<T>::dualConjugated() const

Dual-conjugated dual complex number.

\[ \overline{\hat c} = c_0 - \epsilon c_\epsilon \]

template<class T>
DualComplex<T> Magnum::Math::DualComplex<T>::conjugated() const

Conjugated dual complex number.

Both complex and dual conjugation.

\[ \overline{\hat c^*} = c^*_0 - \epsilon c^*_\epsilon = c^*_0 + \epsilon(-a_\epsilon + ib_\epsilon) \]

template<class T>
T Magnum::Math::DualComplex<T>::lengthSquared() const

Complex number length squared.

Should be used instead of length() for comparing complex number length with other values, because it doesn't compute the square root.

\[ |\hat c|^2 = c_0 \cdot c_0 = |c_0|^2 \]

template<class T>
T Magnum::Math::DualComplex<T>::length() const

Dual quaternion length.

See lengthSquared() which is faster for comparing length with other values.

\[ |\hat c| = \sqrt{c_0 \cdot c_0} = |c_0| \]

template<class T>
DualComplex<T> Magnum::Math::DualComplex<T>::normalized() const

Normalized dual complex number (of unit length)

\[ c' = \frac{c_0}{|c_0|} \]

template<class T>
DualComplex<T> Magnum::Math::DualComplex<T>::inverted() const

Inverted dual complex number.

See invertedNormalized() which is faster for normalized dual complex numbers.

\[ \hat c^{-1} = c_0^{-1} - \epsilon c_\epsilon \]

template<class T>
DualComplex<T> Magnum::Math::DualComplex<T>::invertedNormalized() const

Inverted normalized dual complex number.

Expects that the complex number is normalized.

\[ \hat c^{-1} = c_0^{-1} - \epsilon c_\epsilon = c_0^* - \epsilon c_\epsilon \]

template<class T>
Vector2<T> Magnum::Math::DualComplex<T>::transformVector(const Vector2<T>& vector) const new in 2020.06

Rotate a vector with a dual complex number.

Calls Complex::transformVector() on the real() part, see its documentation for more information.

template<class T>
Vector2<T> Magnum::Math::DualComplex<T>::transformPoint(const Vector2<T>& vector) const

Rotate and translate point with dual complex number.

\[ v' = \hat c v = \hat c ((0 + i) + \epsilon(v_x + iv_y)) \]

template<class T> template<class T>
Debug& operator<<(Debug& debug, const DualComplex<T>& value)

Debug output operator.