Class XMQuaternion
The quaternion functions provided by DirectXMath.
Inherited Members
Namespace: JeremyAnsel.DirectX.DXMath
Assembly: JeremyAnsel.DirectX.DXMath.dll
Syntax
public static class XMQuaternion
Properties
| Edit this page View SourceIdentity
Gets the identity quaternion.
Declaration
public static XMVector Identity { get; }
Property Value
Type | Description |
---|---|
XMVector |
Methods
| Edit this page View SourceBaryCentric(XMVector, XMVector, XMVector, float, float)
Returns a point in barycentric coordinates, using the specified quaternions.
Declaration
public static XMVector BaryCentric(XMVector q0, XMVector q1, XMVector q2, float f, float g)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q0 | The first quaternion in the triangle. |
XMVector | q1 | The second quaternion in the triangle. |
XMVector | q2 | The third quaternion in the triangle. |
float | f | The first weighting factor. |
float | g | The second weighting factor. |
Returns
Type | Description |
---|---|
XMVector | Returns a quaternion in barycentric coordinates. |
BaryCentricV(XMVector, XMVector, XMVector, XMVector, XMVector)
Returns a point in barycentric coordinates, using the specified quaternions.
Declaration
public static XMVector BaryCentricV(XMVector q0, XMVector q1, XMVector q2, XMVector f, XMVector g)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q0 | The first quaternion in the triangle. |
XMVector | q1 | The second quaternion in the triangle. |
XMVector | q2 | The third quaternion in the triangle. |
XMVector | f | The first weighting factor. All components of this vector must be the same. |
XMVector | g | The second weighting factor. All components of this vector must be the same. |
Returns
Type | Description |
---|---|
XMVector | Returns a quaternion in barycentric coordinates. |
Conjugate(XMVector)
Computes the conjugate of a quaternion.
Declaration
public static XMVector Conjugate(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion to conjugate. |
Returns
Type | Description |
---|---|
XMVector | The conjugate of the quaternion. |
Dot(XMVector, XMVector)
Computes the dot product of two quaternions.
Declaration
public static XMVector Dot(XMVector q1, XMVector q2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q1 | The first quaternion. |
XMVector | q2 | The second quaternion. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The dot product between Q1 and Q2 is replicated into each component. |
Equal(XMVector, XMVector)
Tests whether two quaternions are equal.
Declaration
public static bool Equal(XMVector q1, XMVector q2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q1 | The first quaternion to test. |
XMVector | q2 | The second quaternion to test. |
Returns
Type | Description |
---|---|
bool | Returns true if the quaternions are equal and false otherwise. |
Exp(XMVector)
Computes the exponential of a given pure quaternion.
Declaration
public static XMVector Exp(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | Pure quaternion for which to compute the exponential. The w-component of the input quaternion is ignored in the calculation. |
Returns
Type | Description |
---|---|
XMVector | Returns the exponential of Q. |
Inverse(XMVector)
Computes the inverse of a quaternion.
Declaration
public static XMVector Inverse(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion to invert. |
Returns
Type | Description |
---|---|
XMVector | The inverse of Q. |
IsIdentity(XMVector)
Tests whether a specific quaternion is the identity quaternion.
Declaration
public static bool IsIdentity(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion to test. |
Returns
Type | Description |
---|---|
bool | Returns true if Q is the identity quaternion, or false otherwise. |
IsInfinite(XMVector)
Test whether any component of a quaternion is either positive or negative infinity.
Declaration
public static bool IsInfinite(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion to test. |
Returns
Type | Description |
---|---|
bool | Returns true if any component of Q is positive or negative infinity,and false otherwise. |
IsNaN(XMVector)
Test whether any component of a quaternion is a NaN.
Declaration
public static bool IsNaN(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion to test. |
Returns
Type | Description |
---|---|
bool | Returns true if any component of Q is a NaN, and false otherwise. |
Length(XMVector)
Computes the magnitude of a quaternion.
Declaration
public static XMVector Length(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion to measure. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The magnitude of Q is replicated into each component. |
LengthSquare(XMVector)
Computes the square of the magnitude of a quaternion.
Declaration
public static XMVector LengthSquare(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion to measure. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The square of the magnitude is replicated into each component. |
Ln(XMVector)
Computes the natural logarithm of a given unit quaternion.
Declaration
public static XMVector Ln(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | Unit quaternion for which to calculate the natural logarithm. If Q is not a unit quaternion, the returned value is undefined. |
Returns
Type | Description |
---|---|
XMVector | The natural logarithm of Q. |
Multiply(XMVector, XMVector)
Computes the product of two quaternions.
Declaration
public static XMVector Multiply(XMVector q1, XMVector q2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q1 | The first quaternion. |
XMVector | q2 | The second quaternion. |
Returns
Type | Description |
---|---|
XMVector | Returns the product of the two quaternions. |
Normalize(XMVector)
Normalizes a quaternion.
Declaration
public static XMVector Normalize(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion. |
Returns
Type | Description |
---|---|
XMVector | The normalized form of the quaternion. |
NormalizeEst(XMVector)
Estimates the normalized version of a quaternion.
Declaration
public static XMVector NormalizeEst(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion. |
Returns
Type | Description |
---|---|
XMVector | The estimate of the normalized version of a quaternion. |
NotEqual(XMVector, XMVector)
Tests whether two quaternions are not equal.
Declaration
public static bool NotEqual(XMVector q1, XMVector q2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q1 | The first quaternion to test. |
XMVector | q2 | The second quaternion to test. |
Returns
Type | Description |
---|---|
bool | Returns true if the quaternions are unequal and false otherwise. |
ReciprocalLength(XMVector)
Computes the reciprocal of the magnitude of a quaternion.
Declaration
public static XMVector ReciprocalLength(XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q | The quaternion to measure. |
Returns
Type | Description |
---|---|
XMVector | Returns the reciprocal of the magnitude of Q. |
RotationAxis(XMVector, float)
Computes a rotation quaternion about an axis.
Declaration
public static XMVector RotationAxis(XMVector axis, float angle)
Parameters
Type | Name | Description |
---|---|---|
XMVector | axis | 3D vector describing the axis of rotation. |
float | angle | Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. |
Returns
Type | Description |
---|---|
XMVector | Returns the rotation quaternion. |
RotationMatrix(XMMatrix)
Computes a rotation quaternion from a rotation matrix.
Declaration
public static XMVector RotationMatrix(XMMatrix m)
Parameters
Type | Name | Description |
---|---|---|
XMMatrix | m | The rotation matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns the rotation quaternion. |
RotationNormal(XMVector, float)
Computes the rotation quaternion about a normal vector.
Declaration
public static XMVector RotationNormal(XMVector normalAxis, float angle)
Parameters
Type | Name | Description |
---|---|---|
XMVector | normalAxis | Normal vector describing the axis of rotation. |
float | angle | Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin. |
Returns
Type | Description |
---|---|
XMVector | Returns the rotation quaternion. |
RotationRollPitchYaw(float, float, float)
Computes a rotation quaternion based on the pitch, yaw, and roll (Euler angles).
Declaration
public static XMVector RotationRollPitchYaw(float pitch, float yaw, float roll)
Parameters
Type | Name | Description |
---|---|---|
float | pitch | Angle of rotation around the x-axis, in radians. |
float | yaw | Angle of rotation around the y-axis, in radians. |
float | roll | Angle of rotation around the z-axis, in radians. |
Returns
Type | Description |
---|---|
XMVector | Returns the rotation quaternion. |
RotationRollPitchYawFromVector(XMVector)
Computes a rotation quaternion based on a vector containing the Euler angles (pitch, yaw, and roll).
Declaration
public static XMVector RotationRollPitchYawFromVector(XMVector angles)
Parameters
Type | Name | Description |
---|---|---|
XMVector | angles | A 3D vector containing the Euler angles in the order pitch, yaw, roll. |
Returns
Type | Description |
---|---|
XMVector | Returns the rotation quaternion. |
Slerp(XMVector, XMVector, float)
Interpolates between two unit quaternions, using spherical linear interpolation.
Declaration
public static XMVector Slerp(XMVector q0, XMVector q1, float t)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q0 | An unit quaternion to interpolate from. |
XMVector | q1 | An unit quaternion to interpolate to. |
float | t | The interpolation control factor. |
Returns
Type | Description |
---|---|
XMVector | Returns the interpolated quaternion. If Q0 and Q1 are not unit quaternions, the resulting interpolation is undefined. |
SlerpV(XMVector, XMVector, XMVector)
Interpolates between two unit quaternions, using spherical linear interpolation.
Declaration
public static XMVector SlerpV(XMVector q0, XMVector q1, XMVector t)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q0 | An unit quaternion to interpolate from. |
XMVector | q1 | An unit quaternion to interpolate to. |
XMVector | t | The interpolation control factor. All components of this vector must be the same. |
Returns
Type | Description |
---|---|
XMVector | Returns the interpolated quaternion. If Q0 and Q1 are not unit quaternions, the resulting interpolation is undefined. |
Squad(XMVector, XMVector, XMVector, XMVector, float)
Interpolates between four unit quaternions, using spherical quadrangle interpolation.
Declaration
public static XMVector Squad(XMVector q0, XMVector q1, XMVector q2, XMVector q3, float t)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q0 | The first unit quaternion. |
XMVector | q1 | The second unit quaternion. |
XMVector | q2 | The third unit quaternion. |
XMVector | q3 | The fourth unit quaternion. |
float | t | The interpolation control factor. |
Returns
Type | Description |
---|---|
XMVector | Returns the interpolated quaternion. If Q0, Q1, Q2, and Q3 are not all unit quaternions, the returned quaternion is undefined. |
SquadSetup(out XMVector, out XMVector, out XMVector, XMVector, XMVector, XMVector, XMVector)
Provides addresses of setup control points for spherical quadrangle interpolation.
Declaration
public static void SquadSetup(out XMVector a, out XMVector b, out XMVector c, XMVector q0, XMVector q1, XMVector q2, XMVector q3)
Parameters
Type | Name | Description |
---|---|---|
XMVector | a | The first setup quaternion. |
XMVector | b | The second setup quaternion. |
XMVector | c | The third setup quaternion. |
XMVector | q0 | The first quaternion. |
XMVector | q1 | The second quaternion. |
XMVector | q2 | The third quaternion. |
XMVector | q3 | The fourth quaternion. |
SquadV(XMVector, XMVector, XMVector, XMVector, XMVector)
Interpolates between four unit quaternions, using spherical quadrangle interpolation.
Declaration
public static XMVector SquadV(XMVector q0, XMVector q1, XMVector q2, XMVector q3, XMVector t)
Parameters
Type | Name | Description |
---|---|---|
XMVector | q0 | The first unit quaternion. |
XMVector | q1 | The second unit quaternion. |
XMVector | q2 | The third unit quaternion. |
XMVector | q3 | The fourth unit quaternion. |
XMVector | t | The interpolation control factor. All components of this vector must be the same. |
Returns
Type | Description |
---|---|
XMVector | Returns the interpolated quaternion. If Q0, Q1, Q2, and Q3 are not unit quaternions, the resulting interpolation is undefined. |
ToAxisAngle(out XMVector, out float, XMVector)
Computes an axis and angle of rotation about that axis for a given quaternion.
Declaration
public static void ToAxisAngle(out XMVector axis, out float angle, XMVector q)
Parameters
Type | Name | Description |
---|---|---|
XMVector | axis | A 3D vector describing the axis of rotation for the quaternion Q. |
float | angle | The radian angle of rotation for the quaternion Q. |
XMVector | q | The quaternion to measure. |
ToEuler(XMVector)
Computes rotation about y-axis (y), then x-axis (x), then z-axis (z).
Declaration
public static XMVector ToEuler(XMVector quaternion)
Parameters
Type | Name | Description |
---|---|---|
XMVector | quaternion | A quaternion. |
Returns
Type | Description |
---|---|
XMVector | The Euler angles. |