4 #ifndef _3ESQUATERNION_H_ 5 #define _3ESQUATERNION_H_ 9 #include "3esvector3.h" 51 inline Quaternion(
const T &
x,
const T &y,
const T &z,
const T &w) : x(x), y(y), z(z), w(w) {}
59 inline Quaternion(
const T *array4) :
x(array4[0]), y(array4[1]), z(array4[2]), w(array4[3]) {}
71 inline const T &
operator[](
int index)
const {
return q[index]; }
187 template <
typename T>
194 template <
typename T>
206 #include "3esquaternion.inl" 208 #endif // _3ESQUATERNION_H_ T dot(const Quaternion< T > other) const
Calculates the dot product of this and other.
Quaternion< T > & operator=(const Quaternion< T > &other)
Simple assignment operator.
Definition: 3esquaternion.h:76
Quaternion< T > & invert()
Inverts this quaternion, making the counter rotation.
T magnitudeSquared() const
Returns the magnitude squared of this quaternion.
static Quaternion< T > slerp(const Quaternion< T > &from, const Quaternion< T > &to, const T &t)
Performs a spherical linear interpolation of one quaternion to another.
T x
Direct data member access.
Definition: 3esquaternion.h:23
bool isIdentity()
Checks if this quaternion is exactly identity.
Quaternion(const Quaternion< T > &other)
Copy constructor.
Definition: 3esquaternion.h:41
Quaternion()
Default constructor: undefined initialisation behaviour.
Definition: 3esquaternion.h:33
T & operator[](int index)
Index operator.
Definition: 3esquaternion.h:69
static const Quaternion< T > identity
The identity quaternion (0, 0, 0, 1).
Definition: 3esquaternion.h:30
Definition: 3esbounds.h:13
Quaternion(const T *array4)
Initialisation from a array of at least length 4.
Definition: 3esquaternion.h:59
Quaternion< T > & conjugate()
Sets this quaternion to its conjugate.
Quaternion< T > & setAxisAngle(const Vector3< T > &axis, const T &angle)
Sets this quaternion from an axis of rotation and the angle of rotation about that axis (radians)...
Matrix3< T > operator*(const Matrix3< T > &a, const Matrix3< T > &b)
Performs the matrix multiplication AB.
Quaternion(bool)
The identity constructor.
Definition: 3esquaternion.h:37
Quaternion(const Vector3< T > &v, const T &w)
Vector plus scalar initialisation.
Definition: 3esquaternion.h:55
Represents a vector in R3.
Definition: 3esvector3.h:14
Quaternion< T > & operator=(const Quaternion< Q > &other)
Simple assignment operator from a different numeric type.
Definition: 3esquaternion.h:82
Quaternion< T > normalised(const T &epsilon=Vector3< T >::Epsilon) const
Returns a normalised copy of this quaternion.
T normalise(const T &epsilon=Vector3< T >::Epsilon)
Attempts to normalise this quaternion.
Quaternion< T > conjugated() const
Calculates and returns the conjugate of this quaternion.
Quaternion< double > Quaterniond
Defines a double precision quaternion.
Definition: 3esquaternion.h:200
const T & operator[](int index) const
Definition: 3esquaternion.h:71
Vector3< T > transform(const Vector3< T > &v) const
Transforms v by this quaternion rotation.
T q[4]
Array representation of the vector members.
Definition: 3esquaternion.h:26
void getAxisAngle(Vector3< T > &axis, T &angle) const
Converts this quaternion into a axis of rotation and the rotation angle around that axis (radians)...
Quaternion< T > inverse() const
Calculates and returns the inverse of this quaternion.
bool operator==(const Quaternion< T > &other) const
Exact equality operator.
Quaternion< float > Quaternionf
Defines a single precision quaternion.
Definition: 3esquaternion.h:198
bool operator!=(const Quaternion< T > &other) const
Exact inequality operator.
A 4D rotational quaternion class.
Definition: 3esquaternion.h:15
Quaternion(const T &x, const T &y, const T &z, const T &w)
Per coordinate initialisation.
Definition: 3esquaternion.h:51
T magnitude() const
Returns the magnitude of this quaternion.
Quaternion< T > & multiply(const T &scalar)
Multiply all components of this quaternion by a scalar.
bool isEqual(const Quaternion< T > &other, const T &epsilon=Vector3< T >::Epsilon)
Equality test with error.
Quaternion(const Quaternion< Q > &other)
Copy constructor from a different numeric type.
Definition: 3esquaternion.h:45