Go to the documentation of this file.
7 #ifndef INCLUDE_JET_QUATERNION_H_
8 #define INCLUDE_JET_QUATERNION_H_
21 std::is_floating_point<T>::value,
22 "Quaternion only can be instantiated with floating point types");
72 void set(T newW, T newX, T newY, T newZ);
75 void set(
const std::initializer_list<T>& lst);
193 template <
typename T>
200 template <
typename T>
204 template <
typename T>
215 #include "detail/quaternion-inl.h"
217 #endif // INCLUDE_JET_QUATERNION_H_
T w
Real part.
Definition: quaternion.h:22
void set(const Vector3< T > &from, const Vector3< T > &to)
Sets the quaternion with from and to vectors.
Quaternion rmul(const Quaternion &other) const
Returns other quaternion * this quaternion.
Quaternion< U > castTo() const
Returns quaternion with other base type.
Quaternion(const Vector3< T > &from, const Vector3< T > &to)
Constructs a quaternion with from and to vectors.
void normalize()
Normalizes the quaternion.
Quaternion & operator=(const Quaternion &other)
Assigns other quaternion.
Quaternion< double > QuaternionD
Double-type quaternion.
Definition: quaternion.h:211
T l2Norm() const
Returns L2 norm of this quaternion.
Quaternion< T > slerp(const Quaternion< T > &a, const Quaternion< T > &b, T t)
Computes spherical linear interpolation.
Quaternion(const std::initializer_list< T > &lst)
Constructs a quaternion with given elements.
Quaternion mul(const Quaternion &other) const
Returns this quaternion * other quaternion.
T & operator[](size_t i)
Returns the reference to the i-th element.
bool operator!=(const Quaternion &other) const
Returns true if not equal.
Matrix4x4< T > matrix4() const
Converts to the 4x4 rotation matrix.
void set(const std::initializer_list< T > &lst)
Sets the quaternion with given elements.
Quaternion(T newW, T newX, T newY, T newZ)
Constructs a quaternion with given elements.
3-D matrix class.
Definition: matrix3x3.h:28
void set(const Vector3< T > &axis, T angle)
Sets the quaternion with given rotation axis and angle.
T y
Imaginary part (k).
Definition: quaternion.h:31
Quaternion< float > QuaternionF
Float-type quaternion.
Definition: quaternion.h:208
void set(const Matrix3x3< T > &matrix)
Sets the quaternion with 3x3 rotational matrix.
Quaternion class defined as q = w + xi + yj + zk.
Definition: quaternion.h:18
Definition: advection_solver2.h:18
Quaternion normalized() const
Returns normalized quaternion.
void set(const Vector3< T > &rotationBasis0, const Vector3< T > &rotationBasis1, const Vector3< T > &rotationBasis2)
Sets quaternion with three basis vectors.
T x
Imaginary part (j).
Definition: quaternion.h:28
Quaternion & operator*=(const Quaternion &other)
Returns this quaternion *= other quaternion.
Quaternion()
Make an identity quaternion.
T dot(const Quaternion< T > &other)
Computes the dot product with other quaternion.
4-D matrix class.
Definition: matrix4x4.h:27
void getAxisAngle(Vector3< T > *axis, T *angle) const
Returns the axis and angle.
void set(T newW, T newX, T newY, T newZ)
Sets the quaternion with given elements.
T angle() const
Returns the rotational angle.
Quaternion(const Vector3< T > &axis, T angle)
Constructs a quaternion with given rotation axis and angle.
Quaternion(const Vector3< T > &axis0, const Vector3< T > &axis1, const Vector3< T > &axis2)
Constructs a quaternion with three basis vectors.
Quaternion inverse() const
Returns the inverse quaternion.
Vector3< T > mul(const Vector3< T > &v) const
Returns this quaternion * vector.
3-D vector class.
Definition: vector3.h:25
void imul(const Quaternion &other)
Returns this quaternion *= other quaternion.
Quaternion(const Quaternion &other)
Copy constructor.
void setIdentity()
Makes this quaternion identity.
bool operator==(const Quaternion &other) const
Returns true if equal.
Matrix3x3< T > matrix3() const
Converts to the 3x3 rotation matrix.
const T & operator[](size_t i) const
Returns the const reference to the i-th element.
Matrix2x2< T > operator*(const Matrix2x2< T > &a, T b)
Returns a * b', where every element of matrix b' is b.
void set(const Quaternion &other)
Sets the quaternion with other quaternion.
Quaternion(const Matrix3x3< T > &m33)
Constructs a quaternion with 3x3 rotational matrix.
static Quaternion makeIdentity()
Returns identity matrix.
void rotate(T angleInRadians)
Rotate this quaternion with given angle in radians.
T z
Definition: quaternion.h:34
Vector3< T > axis() const
Returns the rotational axis.