| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- $#include "Quaternion.h"
- /// Rotation represented as a four-dimensional normalized vector.
- class Quaternion
- {
- public:
- /// Construct identity quaternion.
- Quaternion();
-
- /// Copy-construct from another quaternion.
- Quaternion(const Quaternion& quat);
-
- /// Construct from values.
- Quaternion(float w, float x, float y, float z);
-
- /// Construct from an angle (in degrees) and axis.
- Quaternion(float angle, const Vector3& axis);
-
- /// Construct from Euler angles (in degrees.)
- Quaternion(float x, float y, float z);
-
- /// Construct from the rotation difference between two vectors.
- Quaternion(const Vector3& start, const Vector3& end);
-
- /// Construct from orthonormal axes.
- Quaternion(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis);
- /// Construct from a rotation matrix.
- Quaternion(const Matrix3& matrix);
-
- /// Test for equality with another quaternion without epsilon.
- bool operator == (const Quaternion& rhs) const;
-
- /// Multiply with a scalar.
- Quaternion operator * (float rhs) const;
-
- /// Return negation.
- Quaternion operator - () const;
-
- /// Add a quaternion.
- Quaternion operator + (const Quaternion& rhs) const;
-
- /// Subtract a quaternion.
- Quaternion operator - (const Quaternion& rhs) const;
-
- /// Multiply a quaternion.
- Quaternion operator * (const Quaternion& rhs) const;
-
- /// Multiply a Vector3.
- Vector3 operator * (const Vector3& rhs) const;
-
-
- /// Define from an angle (in degrees) and axis.
- void FromAngleAxis(float angle, const Vector3& axis);
-
- /// Define from Euler angles (in degrees.)
- void FromEulerAngles(float x, float y, float z);
-
- /// Define from the rotation difference between two vectors.
- void FromRotationTo(const Vector3& start, const Vector3& end);
-
- /// Define from orthonormal axes.
- void FromAxes(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis);
-
- /// Define from a rotation matrix.
- void FromRotationMatrix(const Matrix3& matrix);
-
- /// Normalize to unit length and return the previous length.
- float Normalize();
-
- /// Return normalized to unit length.
- Quaternion Normalized() const;
-
- /// Return inverse.
- Quaternion Inverse() const;
-
- /// Return squared length.
- float LengthSquared() const;
-
- /// Calculate dot product.
- float DotProduct(const Quaternion& rhs) const;
-
- /// Test for equality with another quaternion with epsilon.
- bool Equals(const Quaternion& rhs) const;
-
- /// Return conjugate.
- Quaternion Conjugate() const;
-
- /// Return Euler angles in degrees.
- Vector3 EulerAngles() const;
-
- /// Return yaw angle in degrees.
- float YawAngle() const;
-
- /// Return pitch angle in degrees.
- float PitchAngle() const;
-
- /// Return roll angle in degrees.
- float RollAngle() const;
-
- /// Return the rotation matrix that corresponds to this quaternion.
- Matrix3 RotationMatrix() const;
-
- /// Spherical interpolation with another quaternion.
- Quaternion Slerp(Quaternion rhs, float t) const;
-
- /// W coordinate.
- float w_ @ w;
- /// X coordinate.
- float x_ @ x;
- /// Y coordinate.
- float y_ @ y;
- /// Z coordinate.
- float z_ @ z;
-
- /// Identity quaternion.
- static const Quaternion IDENTITY;
- };
|