Public Member Functions | |
Quaternion ()=default | |
Default constructor, components are uninitialized. | |
Quaternion (const Quaternion &q) | |
Copy constructor, clones the provided quaternion. | |
Quaternion (float x) | |
Constructs quaternion with all components set to the same specified value. | |
Quaternion (float x, float y, float z, float w) | |
Constructs quaternion with all components set to the provided values. | |
Quaternion (const Vector3 &v, float w) | |
Constructs quaternion from a vector3 and scalar w value. | |
Quaternion (Simd::Vec4::FloatArgType value) | |
void | StoreToFloat4 (float *values) const |
Stores the vector to an array of 4 floats. The floats need only be 4 byte aligned, 16 byte alignment is not required. | |
float | GetElement (int index) const |
We recommend using GetX,Y,Z,W. GetElement can be slower. | |
void | SetElement (int index, float v) |
We recommend using SetX,Y,Z,W. SetElement can be slower. | |
float | operator() (int index) const |
void | Set (float x) |
void | Set (float x, float y, float z, float w) |
void | Set (const Vector3 &v, float w) |
void | Set (const float values[]) |
Quaternion | GetConjugate () const |
The conjugate of a quaternion is (-x, -y, -z, w). | |
float | Dot (const Quaternion &q) const |
Dot product. | |
float | GetLengthSq () const |
float | GetLength () const |
Returns length of the quaternion, full accuracy. | |
float | GetLengthEstimate () const |
Returns length of the quaternion, fast but low accuracy, uses raw estimate instructions. | |
float | GetLengthReciprocal () const |
Returns 1/length, full accuracy. | |
float | GetLengthReciprocalEstimate () const |
Returns 1/length of the quaternion, fast but low accuracy, uses raw estimate instructions. | |
Quaternion | GetNormalized () const |
Returns normalized quaternion, full accuracy. | |
Quaternion | GetNormalizedEstimate () const |
Returns normalized quaternion, fast but low accuracy, uses raw estimate instructions. | |
void | Normalize () |
Normalizes the quaternion in-place, full accuracy. | |
void | NormalizeEstimate () |
Normalizes the quaternion in-place, fast but low accuracy, uses raw estimate instructions. | |
Quaternion | Lerp (const Quaternion &dest, float t) const |
Quaternion | NLerp (const Quaternion &dest, float t) const |
Quaternion | Slerp (const Quaternion &dest, float t) const |
Spherical linear interpolation. Result is not normalized. | |
Quaternion | Squad (const Quaternion &dest, const Quaternion &in, const Quaternion &out, float t) const |
bool | IsClose (const Quaternion &q, float tolerance=Constants::Tolerance) const |
Checks if the quaternion is close to another quaternion with a given floating point tolerance. | |
bool | IsIdentity (float tolerance=Constants::Tolerance) const |
bool | IsZero (float tolerance=Constants::FloatEpsilon) const |
Quaternion & | operator= (const Quaternion &rhs) |
Quaternion | operator- () const |
Quaternion | operator+ (const Quaternion &q) const |
Quaternion | operator- (const Quaternion &q) const |
Quaternion | operator* (const Quaternion &q) const |
Quaternion | operator* (float multiplier) const |
Quaternion | operator/ (float divisor) const |
Quaternion & | operator+= (const Quaternion &q) |
Quaternion & | operator-= (const Quaternion &q) |
Quaternion & | operator*= (const Quaternion &q) |
Quaternion & | operator*= (float multiplier) |
Quaternion & | operator/= (float divisor) |
bool | operator== (const Quaternion &rhs) const |
bool | operator!= (const Quaternion &rhs) const |
Vector3 | TransformVector (const Vector3 &v) const |
Transforms a vector using the rotation described by this quaternion. | |
Vector3 | GetEulerDegrees () const |
Vector3 | GetEulerRadians () const |
Vector3 | GetEulerDegreesXYZ () const |
Vector3 | GetEulerRadiansXYZ () const |
Vector3 | GetEulerDegreesYXZ () const |
Vector3 | GetEulerRadiansYXZ () const |
Vector3 | GetEulerDegreesZYX () const |
Vector3 | GetEulerRadiansZYX () const |
void | SetFromEulerRadians (const Vector3 &eulerRadians) |
void | SetFromEulerDegrees (const Vector3 &eulerDegrees) |
void | ConvertToAxisAngle (Vector3 &outAxis, float &outAngle) const |
Vector3 | ConvertToScaledAxisAngle () const |
Convert the quaternion into scaled axis-angle representation. | |
Vector3 | GetImaginary () const |
Returns the imaginary (X/Y/Z) portion of the quaternion. | |
float | GetAngle () const |
Return angle in radians. | |
bool | IsFinite () const |
Simd::Vec4::FloatType | GetSimdValue () const |
float | GetX () const |
float | GetY () const |
float | GetZ () const |
float | GetW () const |
void | SetX (float x) |
void | SetY (float y) |
void | SetZ (float z) |
void | SetW (float w) |
Quaternion | GetInverseFast () const |
void | InvertFast () |
Quaternion | GetInverseFull () const |
void | InvertFull () |
float | NormalizeWithLength () |
float | NormalizeWithLengthEstimate () |
Quaternion | GetShortestEquivalent () const |
void | ShortestEquivalent () |
Static Public Member Functions | |
static void | Reflect (ReflectContext *context) |
static Quaternion | CreateIdentity () |
static Quaternion | CreateZero () |
static Quaternion | CreateFromFloat4 (const float *values) |
Sets components from an array of 4 floats, stored in xyzw order. | |
static Quaternion | CreateFromVector3 (const Vector3 &v) |
Sets components using a Vector3 for the imaginary part and setting the real part to zero. | |
static Quaternion | CreateFromVector3AndValue (const Vector3 &v, float w) |
Sets components using a Vector3 for the imaginary part and a float for the real part. | |
static Quaternion | CreateFromEulerRadiansXYZ (const Vector3 &eulerRadians) |
static Quaternion | CreateFromEulerRadiansYXZ (const Vector3 &eulerRadians) |
static Quaternion | CreateFromEulerRadiansZYX (const Vector3 &eulerRadians) |
static Quaternion | CreateFromEulerDegreesXYZ (const Vector3 &eulerDegrees) |
static Quaternion | CreateFromEulerDegreesYXZ (const Vector3 &eulerDegrees) |
static Quaternion | CreateFromEulerDegreesZYX (const Vector3 &eulerDegrees) |
static Quaternion | CreateFromMatrix3x3 (const class Matrix3x3 &m) |
Creates a quaternion from a Matrix3x3. | |
static Quaternion | CreateFromMatrix3x4 (const class Matrix3x4 &m) |
static Quaternion | CreateFromMatrix4x4 (const class Matrix4x4 &m) |
Creates a quaternion using the rotation part of a Matrix4x4. | |
static Quaternion | CreateFromBasis (const Vector3 &basisX, const Vector3 &basisY, const Vector3 &basisZ) |
Creates a quaternion from a set of basis vectors. | |
static Quaternion | CreateFromAxisAngle (const Vector3 &axis, float angle) |
static Quaternion | CreateFromScaledAxisAngle (const Vector3 &scaledAxisAngle) |
Create a quaternion from a scaled axis-angle representation. | |
static Quaternion | CreateShortestArc (const Vector3 &v1, const Vector3 &v2) |
static const Quaternion | CreateFromEulerAnglesDegrees (const Vector3 &anglesInDegrees) |
static const Quaternion | CreateFromEulerAnglesRadians (const Vector3 &anglesInRadians) |
static Quaternion | CreateRotationX (float angleInRadians) |
static Quaternion | CreateRotationY (float angleInRadians) |
static Quaternion | CreateRotationZ (float angleInRadians) |
|
explicit |
Constructs quaternion from a SIMD type. For internal use only, arrangement of values in SIMD type is not guaranteed.
Populate axis and angle of rotation from Quaternion
[out] | outAxis | A Vector3 defining the rotation axis. |
[out] | outAngle | A float rotation angle around the axis in radians. |
|
static |
O3DE_DEPRECATION_NOTICE(GHI-10929)
|
static |
O3DE_DEPRECATION_NOTICE(GHI-10929)
|
static |
Creates a quaternion using the left 3x3 part of a Matrix3x4.
|
static |
Sets the quaternion to be a rotation around a specified axis in radians.
AZ_MATH_INLINE Vector3 AZ::Quaternion::GetEulerDegrees | ( | ) | const |
Create, from the quaternion, a set of Euler (actually Tait-Bryan) angles of rotations around: first x-axis, then y-axis and then z-axis.
AZ_MATH_INLINE Vector3 AZ::Quaternion::GetEulerDegreesXYZ | ( | ) | const |
Compute, from the quaternion, a set of Euler (actually Tait-Bryan) angles of rotations around: first x-axis (roll), then y-axis (pitch) and then z-axis (yaw). The quaternion us supposed to be created with CreateFromEulerRadiansXYZ() or CreateFromEulerDegreesXYZ(). Note that a gimbal lock occurs with the y-axis rotation equal to +-90 degrees, loosing information on initial yaw and roll, and then roll is deliberately zeroed.
AZ_MATH_INLINE Vector3 AZ::Quaternion::GetEulerDegreesYXZ | ( | ) | const |
Compute, from the quaternion, a set of Euler (actually Tait-Bryan) angles of rotations around: first y-axis (pitch), then x-axis (roll) and then z-axis (yaw). The quaternion us supposed to be created with CreateFromEulerRadiansYXZ() or CreateFromEulerDegreesYXZ().
AZ_MATH_INLINE Vector3 AZ::Quaternion::GetEulerDegreesZYX | ( | ) | const |
Compute, from the quaternion, a set of Euler (actually Tait-Bryan) angles of rotations around: first z-axis (yaw), then y-axis (pitch) and then x-axis (roll). The quaternion us supposed to be created with CreateFromEulerRadiansZYX() or CreateFromEulerDegreesZYX(). Note that a gimbal lock occurs with the y-axis rotation equal to +-90 degrees, loosing information on initial yaw and roll, and then roll is deliberately zeroed.
Vector3 AZ::Quaternion::GetEulerRadians | ( | ) | const |
Create, from the quaternion, a set of Euler (actually Tait-Bryan) angles of rotations around: first x-axis, then y-axis and then z-axis.
Vector3 AZ::Quaternion::GetEulerRadiansXYZ | ( | ) | const |
Compute, from the quaternion, a set of Euler (actually Tait-Bryan) angles of rotations around: first x-axis (roll), then y-axis (pitch) and then z-axis (yaw). The quaternion us supposed to be created with CreateFromEulerRadiansXYZ() or CreateFromEulerDegreesXYZ(). Note that a gimbal lock occurs with the y-axis rotation equal to +-90 degrees, loosing information on initial yaw and roll, and then roll is deliberately zeroed.
Vector3 AZ::Quaternion::GetEulerRadiansYXZ | ( | ) | const |
Compute, from the quaternion, a set of Euler (actually Tait-Bryan) angles of rotations around: first y-axis (pitch), then x-axis (roll) and then z-axis (yaw). The quaternion us supposed to be created with CreateFromEulerRadiansYXZ() or CreateFromEulerDegreesYXZ().
Vector3 AZ::Quaternion::GetEulerRadiansZYX | ( | ) | const |
Compute, from the quaternion, a set of Euler (actually Tait-Bryan) angles of rotations around: first z-axis (yaw), then y-axis (pitch) and then x-axis (roll). The quaternion us supposed to be created with CreateFromEulerRadiansZYX() or CreateFromEulerDegreesZYX(). Note that a gimbal lock occurs with the y-axis rotation equal to +-90 degrees, loosing information on initial yaw and roll, and then roll is deliberately zeroed.
AZ_MATH_INLINE Quaternion AZ::Quaternion::GetInverseFast | ( | ) | const |
For a unit quaternion, the inverse is just the conjugate. This function assumes a unit quaternion.
AZ_MATH_INLINE Quaternion AZ::Quaternion::GetInverseFull | ( | ) | const |
This is the inverse for any quaternion, not just unit quaternions.
AZ_MATH_INLINE Quaternion AZ::Quaternion::GetShortestEquivalent | ( | ) | const |
Get the shortest equivalent of the rotation. In case the w component of the quaternion is negative the rotation is > 180° and taking the longer path. The quaternion will be inverted in that case to take the shortest path of rotation.
AZ_MATH_INLINE Quaternion AZ::Quaternion::Lerp | ( | const Quaternion & | dest, |
float | t | ||
) | const |
Linearly interpolate towards a destination quaternion.
[in] | dest | The quaternion to interpolate towards. |
[in] | t | Normalized interpolation value where 0.0 represents the current and 1.0 the destination value. |
AZ_MATH_INLINE Quaternion AZ::Quaternion::NLerp | ( | const Quaternion & | dest, |
float | t | ||
) | const |
Linearly interpolate towards a destination quaternion, and normalize afterwards.
[in] | dest | The quaternion to interpolate towards. |
[in] | t | Normalized interpolation value where 0.0 represents the current and 1.0 the destination value. |
AZ_MATH_INLINE float AZ::Quaternion::NormalizeWithLength | ( | ) |
Normalizes the vector in-place and returns the previous length. This takes a few more instructions than calling just Normalize().
Indexed access using operator(). It's just for convenience.
|
static |
AzCore Reflection.
context | reflection context |
eulerDegrees | A vector containing component-wise rotation angles in degrees. O3DE_DEPRECATION_NOTICE(GHI-10929) |
eulerRadians | A vector containing component-wise rotation angles in radians. O3DE_DEPRECATION_NOTICE(GHI-10929) |
AZ_MATH_INLINE Quaternion AZ::Quaternion::Squad | ( | const Quaternion & | dest, |
const Quaternion & | in, | ||
const Quaternion & | out, | ||
float | t | ||
) | const |
Spherical linear interpolation, but with in/out tangent quaternions. Squad(p,a,b,q,t) = Slerp(Slerp(p,q,t), Slerp(a,b,t); 2(1-t)t).