51 q.X = (Z.
Y - Y.
Z) / square;
52 q.Y = (X.
Z - Z.
X) / square;
53 q.Z = (Y.
X - X.
Y) / square;
55 else if ((X.
X > Y.
Y) && (X.
X > Z.
Z)){
56 square =
sqrtf(1.0f + X.
X - Y.
Y - Z.
Z) * 2.0f;
58 q.W = (Z.
Y - Y.
Z) / square;
60 q.Y = (X.
Y + Y.
X) / square;
61 q.Z = (X.
Z + Z.
X) / square;
64 square =
sqrtf(1.0f + Y.
Y - X.
X - Z.
Z) * 2.0f;
66 q.W = (X.
Z - Z.
X) / square;
67 q.X = (X.
Y + Y.
X) / square;
69 q.Z = (Y.
Z + Z.
Y) / square;
72 square =
sqrtf(1.0f + Z.
Z - X.
X - Y.
Y) * 2.0f;
74 q.W = (Y.
X - X.
Y) / square;
75 q.X = (X.
Z + Z.
X) / square;
76 q.Y = (Y.
Z + Z.
Y) / square;
80 return q.UnitQuaternion().Conjugate();
162 if (
dot < -0.999999f)
166 if (
tempV.Magnitude() < 0.000001f)
175 else if (
dot > 0.999999f)
191 q =
q.UnitQuaternion();
242 q = (
fabs(
q.W) > 1.0f) ?
q.UnitQuaternion() :
q;
303 float sqx =
q.X *
q.X;
304 float sqy =
q.Y *
q.Y;
305 float sqz =
q.Z *
q.Z;
307 switch (
order.AxisOrder) {
Provides a collection of mathematical utility functions and constants.
Defines the Rotation class for handling 3D rotations using various representations.
Defines a rotation in 3D space using an axis and an angle.
Defines a rotation in 3D space using a direction vector and a rotation angle.
Encapsulates a 3D rotation using Euler angles and a specific order of application.
Specifies the order and frame of reference for Euler rotations.
@ YZX
Y → Z → X rotation order.
@ XZY
X → Z → Y rotation order.
@ ZYX
Z → Y → X rotation order.
@ YXZ
Y → X → Z rotation order.
@ ZXY
Z → X → Y rotation order.
@ XYZ
X → Y → Z rotation order.
@ Rotating
Rotations relative to a rotating frame.
Implements a generic Kalman Filter for 1D data.
static T RadiansToDegrees(T radians)
Converts radians to degrees.
static const float MPI
Mathematical constant (3.14159265358979323846...).
static T DegreesToRadians(T degrees)
Converts degrees to radians.
A mathematical construct representing a rotation in 3D space.
Quaternion UnitQuaternion() const
Returns a unit quaternion (normalized) version of this quaternion.
Vector2D RotateVector(const Vector2D &v) const
Rotates a 2D vector by this quaternion, projecting it in 2D.
Represents a 3D rotation matrix and provides operations for rotation and matrix manipulation.
static Vector3D RotateVector(Vector3D rotate, Vector3D coordinates)
Rotates a vector using the rotation matrix.
EulerAngles RotationMatrixToEulerAngles(const RotationMatrix &rM, const EulerOrder &order)
Converts a RotationMatrix to Euler angles.
YawPitchRoll GetYawPitchRoll()
Gets the yaw-pitch-roll representation of the rotation.
RotationMatrix EulerAnglesToRotationMatrix(const EulerAngles &eulerAngles)
Converts Euler angles to a RotationMatrix.
Quaternion EulerAnglesToQuaternion(const EulerAngles &eulerAngles)
Converts Euler angles to a Quaternion.
Quaternion YawPitchRollToQuaternion(const YawPitchRoll &ypr)
Converts a YawPitchRoll representation to a Quaternion.
AxisAngle GetAxisAngle()
Gets the axis-angle representation of the rotation.
RotationMatrix GetRotationMatrix()
Gets the rotation matrix representation of the rotation.
EulerAngles GetEulerAngles(const EulerOrder &order)
Gets the Euler angles representation of the rotation.
Rotation()
Default constructor.
Quaternion GetQuaternion()
Gets the quaternion representation of the rotation.
DirectionAngle GetDirectionAngle()
Gets the direction-angle representation of the rotation.
Quaternion RotationMatrixToQuaternion(const RotationMatrix &rM)
Converts a RotationMatrix to a Quaternion.
Quaternion quaternionRotation
Quaternion representation of the rotation.
Quaternion DirectionAngleToQuaternion(const DirectionAngle &directionAngle)
Converts a DirectionAngle to a Quaternion.
Quaternion AxisAngleToQuaternion(const AxisAngle &axisAngle)
Converts an AxisAngle to a Quaternion.
Quaternion QuaternionFromDirectionVectors(const Vector3D &initial, const Vector3D &target)
Creates a Quaternion from direction vectors.
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Vector3D CrossProduct(const Vector3D &vector) const
Computes the cross product of this vector with another Vector3D.
float Z
The Z-component of the 3D vector.
float X
The X-component of the 3D vector.
float Y
The Y-component of the 3D vector.
float DotProduct(const Vector3D &vector) const
Computes the dot product of this vector with another Vector3D.
A class to represent yaw, pitch, and roll angles for orientation.