14 #ifndef SRC_QUATERNION_H_
15 #define SRC_QUATERNION_H_
74 float x()
const {
return q[0]; }
77 float y()
const {
return q[1]; }
80 float z()
const {
return q[2]; }
83 float w()
const {
return q[3]; }
A quaternion to represent rotations in 3D space.
Quaternion Slerp(const Quaternion &other, float alpha) const
Uses spherical interpolation to interpoloate between the rotation stored in this quaternion and the r...
Vector3 ToEulerAnglesZYX() const
Converts the rotation specified by the quaternion into Euler angles.
void Normalize()
Normalizes the quat by making it unit length.
Quaternion(float *ptr)
Creates a quate from a pointer to 4 floating point numbers in the order qx, qy, qz,...
Quaternion(const Quaternion &other)
Copy constructor.
static Quaternion Slerp(const Quaternion &a, const Quaternion &b, float alpha)
Uses spherical interpolation to interpoloate between the rotations specified by two quaternions.
Quaternion ToUnit() const
Returns a normalized (i.e., unit length) version of the quaternion without modifying the original.
float & operator[](const int i)
Writable access the ith coordinate of the quaternion (qx, qy, qz, qw).
float operator[](const int i) const
Read only access to the ith coordinate of the quaternion (qx, qy, qz, qw).
static Quaternion FromAxisAngle(const Vector3 &axis, float angle)
Creates a new quaternion that describes a rotation by angle radians about.
Quaternion(float qx, float qy, float qz, float qw)
Creates a quat from the 4 parameters.
float z() const
Read only access to the z coordinate of the imaginary part of the quaternion.
float x() const
Read only access to the x coordinate of the imaginary part of the quaternion.
float w() const
Read only access to the w, real part, of the quaternion.
float Dot(const Quaternion &q) const
Returns the dot product of this quaternion with another.
static Quaternion FromEulerAnglesZYX(const Vector3 &angles)
Creates a new quaternion from a rotation defined in Euler angles.
bool operator==(const Quaternion &q) const
Check for "equality", taking floating point imprecision into account.
Quaternion Conjugate() const
Returns the conjugate of the quaternion.
const float * value_ptr() const
Returns a const pointer to the raw data array, stored in the order qx, qy, qz, qw.
Quaternion & operator=(const Quaternion &q)
Assignment operator.
Quaternion()
Creates a quat with the identity rotation.
bool operator!=(const Quaternion &q) const
Check for "inequality", taking floating point imprecision into account.
float y() const
Read only access to the y coordinate of the imaginary part of the quaternion.
float Length() const
Returns the length of the quaternion.
A 3D Vector with floating point coordinates, used for storing normals and all sorts of other 3D graph...
Namespace for the MinGfx Toolkit.
Quaternion operator-(const Quaternion &q)
AABB operator+(const AABB &A, const AABB &B)
Quaternion operator/(const Quaternion &q, const float s)
std::ostream & operator<<(std::ostream &os, const Color &c)
std::istream & operator>>(std::istream &is, Color &c)
Matrix4 operator*(const Matrix4 &m, const float &s)
Multiply matrix and scalar, returns the new matrix.