template<class T>
Complex class
Complex number.
Template parameters | |
---|---|
T | Data type |
Contents
Represents 2D rotation. See 2D and 3D transformations for brief introduction.
Public types
- using Type = T
- Underlying data type.
Public static functions
Constructors, destructors, conversion operators
- Complex(IdentityInitT = IdentityInit) constexpr noexcept
- Default constructor.
- Complex(ZeroInitT) explicit constexpr noexcept
- Construct zero-initialized complex number.
- Complex(NoInitT) explicit noexcept
- Construct without initializing the contents.
- Complex(T real, T imaginary) constexpr noexcept
- Construct complex number from real and imaginary part.
- Complex(const Vector2<T>& vector) explicit constexpr noexcept
- Construct complex number from vector.
-
template<class U>Complex(const Complex<U>& other) explicit constexpr noexcept
- Construct complex number from another of different type.
-
template<class U, class V = decltype(Implementation::ComplexConverter<T, U>::from(std::Complex(const U& other) explicit constexpr
declval<U>()))> - Construct complex number from external representation.
- Complex(const Complex<T>&) noexcept defaulted constexpr
- Copy constructor.
-
template<class U, class V = decltype(Implementation::ComplexConverter<T, U>::to(std::operator U() const explicit constexpr
declval<Complex<T>>()))> - Convert complex number to external representation.
- operator Vector2<T>() const explicit constexpr
- Convert complex number to vector.
Public functions
- auto operator==(const Complex<T>& other) const -> bool
- Equality comparison.
- auto operator!=(const Complex<T>& other) const -> bool
- Non-equality comparison.
- auto isNormalized() const -> bool
- Whether the complex number is normalized.
- auto real() const -> T constexpr
- Real part.
- auto imaginary() const -> T constexpr
- Imaginary part.
- auto angle() const -> Rad<T>
- Rotation angle of complex number.
- auto toMatrix() const -> Matrix2x2<T>
- Convert complex number to rotation matrix.
- auto operator+=(const Complex<T>& other) -> Complex<T>&
- Add complex number and assign.
- auto operator+(const Complex<T>& other) const -> Complex<T>
- Add complex number.
- auto operator-() const -> Complex<T>
- Negated complex number.
- auto operator-=(const Complex<T>& other) -> Complex<T>&
- Subtract complex number and assign.
- auto operator-(const Complex<T>& other) const -> Complex<T>
- Subtract complex number.
- auto operator*=(T scalar) -> Complex<T>&
- Multiply with scalar and assign.
- auto operator*(T scalar) const -> Complex<T>
- Multiply with scalar.
- auto operator/=(T scalar) -> Complex<T>&
- Divide with scalar and assign.
- auto operator/(T scalar) const -> Complex<T>
- Divide with scalar.
- auto operator*(const Complex<T>& other) const -> Complex<T>
- Multiply with complex number.
- auto dot() const -> T
- Dot product of the complex number.
- auto length() const -> T
- Complex number length.
- auto normalized() const -> Complex<T>
- Normalized complex number (of unit length)
- auto conjugated() const -> Complex<T>
- Conjugated complex number.
- auto inverted() const -> Complex<T>
- Inverted complex number.
- auto invertedNormalized() const -> Complex<T>
- Inverted normalized complex number.
- auto transformVector(const Vector2<T>& vector) const -> Vector2<T>
- Rotate vector with complex number.
Function documentation
template<class T>
static Complex<T> Magnum:: Math:: Complex<T>:: fromMatrix(const Matrix2x2<T>& matrix)
Create complex number from rotation matrix.
Expects that the matrix is orthogonal (i.e. pure rotation).
template<class T>
Magnum:: Math:: Complex<T>:: Complex(IdentityInitT = IdentityInit) constexpr noexcept
Default constructor.
Constructs unit complex number.
template<class T>
Magnum:: Math:: Complex<T>:: Complex(T real,
T imaginary) constexpr noexcept
Construct complex number from real and imaginary part.
template<class T>
Magnum:: Math:: Complex<T>:: operator Vector2<T>() const explicit constexpr
Convert complex number to vector.
template<class T>
bool Magnum:: Math:: Complex<T>:: isNormalized() const
Whether the complex number is normalized.
Complex number is normalized if it has unit length:
template<class T>
Complex<T>& Magnum:: Math:: Complex<T>:: operator+=(const Complex<T>& other)
Add complex number and assign.
The computation is done in-place.
template<class T>
Complex<T>& Magnum:: Math:: Complex<T>:: operator-=(const Complex<T>& other)
Subtract complex number and assign.
The computation is done in-place.
template<class T>
Complex<T>& Magnum:: Math:: Complex<T>:: operator*=(T scalar)
Multiply with scalar and assign.
The computation is done in-place.
template<class T>
Complex<T>& Magnum:: Math:: Complex<T>:: operator/=(T scalar)
Divide with scalar and assign.
The computation is done in-place.
template<class T>
T Magnum:: Math:: Complex<T>:: length() const
Complex number length.
See also dot() const which is faster for comparing length with other values.
template<class T>
Complex<T> Magnum:: Math:: Complex<T>:: normalized() const
Normalized complex number (of unit length)
template<class T>
Complex<T> Magnum:: Math:: Complex<T>:: conjugated() const
Conjugated complex number.
template<class T>
Complex<T> Magnum:: Math:: Complex<T>:: inverted() const
Inverted complex number.
See invertedNormalized() which is faster for normalized complex numbers.
template<class T>
Complex<T> Magnum:: Math:: Complex<T>:: invertedNormalized() const
Inverted normalized complex number.
Equivalent to conjugated(). Expects that the complex number is normalized.
template<class T>
Vector2<T> Magnum:: Math:: Complex<T>:: transformVector(const Vector2<T>& vector) const
Rotate vector with complex number.
template<class T>
template<class T>
Complex<T> operator*(T scalar,
const Complex<T>& complex)
Multiply scalar with complex.
Same as Complex::
template<class T>
template<class T>
Corrade:: Utility:: Debug& operator<<(Corrade:: Utility:: Debug& debug,
const Complex<T>& value)
Debug output operator.