basic_quaternion
namespace nin {
template <std::floating_point T>
struct basic_quaternion;
using quaternion = basic_quaternion<double>;
}
A Hamilton quaternion q = w + xi + yj + zk with full arithmetic support. All four components default to zero.
The type alias quaternion is provided for basic_quaternion<double>.
Member functions
(Constructor)
constructs a quaternion
(Constructor)
constructs a quaternion
|
(1) |
|
(2) |
|
(3) |
-
(1) Default constructor. All components are zero.
-
(2) Explicit converting constructor from a different floating-point type.
-
(3) Component constructor.
conjugate
conjugates the quaternion in place
conjugate
conjugates the quaternion in place
|
(1) |
Negates the imaginary components (x, y, z).
normalize
normalises the quaternion in place
normalize
normalises the quaternion in place
|
(1) |
Divides every component by norm(*this).
invert
inverts the quaternion in place
invert
inverts the quaternion in place
|
(1) |
Conjugates and divides by the squared norm.
operator+, operator- (unary)
unary plus and negation
operator+, operator- (unary)
unary plus and negation
|
(1) |
|
(2) |
-
(1) Returns a copy.
-
(2) Returns the quaternion with all components negated.
operator+=, operator-=, operator*=, operator/=
compound assignment with another quaternion
operator+=, operator-=, operator*=, operator/=
compound assignment with another quaternion
|
(1) |
|
(2) |
|
(3) |
|
(4) |
Hamilton product for (3); right-multiply by inverse for (4).
operator+=, operator-=, operator*=, operator/= (scalar)
compound assignment with a scalar
operator+=, operator-=, operator*=, operator/= (scalar)
compound assignment with a scalar
|
(1) |
|
(2) |
|
(3) |
|
(4) |
Scalar operations apply to every component for (3) and (4), and to the real part for (1) and (2).
Non-member functions
norm2, norm
squared norm and norm
norm2, norm
squared norm and norm
|
(1) |
|
(2) |
conj, inv
conjugate and inverse (out-of-place)
conj, inv
conjugate and inverse (out-of-place)
|
(1) |
|
(2) |
operator+, operator-, operator*, operator/
binary arithmetic
operator+, operator-, operator*, operator/
binary arithmetic
|
quaternion-quaternion and scalar |
|
quaternion-quaternion and scalar |
|
quaternion-quaternion and scalar |
|
quaternion-quaternion and scalar |
Mixed quaternion-scalar overloads are provided for all operators except scalar / quaternion.
real, imag
real and imaginary projections
real, imag
real and imaginary projections
|
(1) |
|
(2) |
|
(3) |
-
(1)-(2) Returns the scalar part w.
-
(3) Returns the vector part {x, y, z}.