Navigation
API > API/Runtime > API/Runtime/Core
Floating point quaternion that can represent a rotation about an axis in 3-D space. The X, Y, Z, W components also double as the Axis/Angle format.
Order matters when composing quaternions: C = A * B will yield a quaternion C that logically first applies B then A to any subsequent transformation (right first, then left). Note that this is the opposite order of FTransform multiplication.
Example: LocalToWorld = (LocalToWorld * DeltaRotation) will change rotation in local space by DeltaRotation. Example: LocalToWorld = (DeltaRotation * LocalToWorld) will change rotation in world space by DeltaRotation.
| Name | TQuat |
| Type | struct |
| Header File | /Engine/Source/Runtime/Core/Public/Math/MathFwd.h |
| Include Path | #include "Math/MathFwd.h" |
| Source | /Engine/Source/Runtime/Core/Public/Math/Quat.h |
Syntax
template<typename T>
struct TQuat
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Conversion to other type. | Math/Quat.h | ||
TQuat
(
QuatVectorRegister V |
Creates and initializes a new quaternion from the XYZW values in the given VectorRegister4Float. | Math/Quat.h | |
| Creates and initializes a new quaternion from the given matrix. | Math/Quat.h | ||
| Creates and initializes a new quaternion from the given rotator. | Math/Quat.h | ||
| Creates and initializes a new quaternion from the a rotation around the given axis. | Math/Quat.h | ||
TQuat
(
EForceInit |
Creates and initializes a new quaternion, with the W component either 0 or 1. | Math/Quat.h | |
TQuat () |
Default constructor (no initialization). | Math/Quat.h | |
TQuat
(
T V |
Initializes all elements to V | Math/Quat.h | |
TQuat
(
T InX, |
Constructor. | Math/Quat.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FReal | T | Can't have a UE_REQUIRES in the declaration because of the forward declarations, so check for allowed types here. | Math/Quat.h |
| QuatVectorRegister | TVectorRegisterType< T > | Math/Quat.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| Identity | const TQuat< T > | Identity quaternion. | Math/Quat.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| W | T | The quaternion's W-component. | Math/Quat.h | |
| X | T | The quaternion's X-component. | Math/Quat.h | |
| Y | T | The quaternion's Y-component. | Math/Quat.h | |
| Z | T | The quaternion's Z-component. | Math/Quat.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
T AngularDistance
(
const TQuat< T >& Q |
Find the angular distance between two rotation quaternions (in radians) | Math/Quat.h | |
bool ContainsNaN() |
Utility to check if there are any non-finite values (NaN or Inf) in this Quat. | Math/Quat.h | |
void DiagnosticCheckNaN
(
const TCHAR* Message |
Math/Quat.h | ||
void DiagnosticCheckNaN () |
Math/Quat.h | ||
void EnforceShortestArcWith
(
const TQuat< T >& OtherQuat |
Enforce that the delta between this Quaternion and another one represents the shortest possible rotation angle | Math/Quat.h | |
bool Equals
(
const TQuat< T >& Q, |
Checks whether another Quaternion is equal to this, within specified tolerance. | Math/Quat.h | |
TVector< T > Euler() |
Convert a Quaternion into floating-point Euler angles (in degrees). | Math/Quat.h | |
| Exp should really only be used after Log. | Math/Quat.h | ||
T GetAngle () |
Get the angle in radians of this quaternion | Math/Quat.h | |
TVector< T > GetAxisX() |
Get the forward direction (X axis) after it has been rotated by this Quaternion. | Math/Quat.h | |
TVector< T > GetAxisY() |
Get the right direction (Y axis) after it has been rotated by this Quaternion. | Math/Quat.h | |
TVector< T > GetAxisZ() |
Get the up direction (Z axis) after it has been rotated by this Quaternion. | Math/Quat.h | |
TVector< T > GetForwardVector() |
Get the forward direction (X axis) after it has been rotated by this Quaternion. | Math/Quat.h | |
TQuat< T > GetNormalized
(
T Tolerance |
Get a normalized copy of this quaternion. If it is too small, returns an identity quaternion. | Math/Quat.h | |
TVector< T > GetRightVector() |
Get the right direction (Y axis) after it has been rotated by this Quaternion. | Math/Quat.h | |
TVector< T > GetRotationAxis () |
Get the axis of rotation of the Quaternion. | Math/Quat.h | |
| Returns the version of this quaternion that represents the shortest rotation angle to the other quaternion | Math/Quat.h | ||
T GetTwistAngle
(
const TVector< T >& TwistAxis |
Get the twist angle (in radians) for a specified axis | Math/Quat.h | |
TVector< T > GetUpVector() |
Get the up direction (Z axis) after it has been rotated by this Quaternion. | Math/Quat.h | |
| Identical implementation for TQuat properties. | Math/Quat.h | ||
bool InitFromString
(
const FString& InSourceString |
Initialize this TQuat from a FString. | Math/Quat.h | |
| : Requires this quaternion to be normalized. | Math/Quat.h | ||
bool IsIdentity
(
T Tolerance |
Checks whether this Quaternion is an Identity Quaternion. Assumes Quaternion tested is normalized. | Math/Quat.h | |
bool IsNormalized() |
Return true if this quaternion is normalized. | Math/Quat.h | |
| : The rotation returned may not be the shortest version. | Math/Quat.h | ||
bool NetSerialize
(
FArchive& Ar, |
Serializes the vector compressed for e.g. network transmission. | Math/Quat.h | |
void Normalize
(
T Tolerance |
Normalize this quaternion if it is large enough. | Math/Quat.h | |
| Rotate a vector by this quaternion. | Math/Quat.h | ||
TRotator< T > Rotator() |
Forward declare all explicit specializations (in UnrealMath.cpp) | Math/Quat.h | |
bool Serialize
(
FArchive& Ar |
Math/Quat.h | ||
| Math/Quat.h | |||
T Size() |
Get the length of this quaternion. | Math/Quat.h | |
T SizeSquared() |
Get the length squared of this quaternion. | Math/Quat.h | |
void ToAxisAndAngle
(
TVector< T >& Axis, |
Math/Quat.h | ||
void ToAxisAndAngle
(
TVector< T >& Axis, |
Get the axis and angle of rotation of this quaternion | Math/Quat.h | |
TTuple< T, T, T > ToLUFEuler() |
Math/Quat.h | ||
| Get the TMatrix |
Math/Quat.h | ||
| Get the TMatrix |
Math/Quat.h | ||
TVector< T > ToRotationVector () |
Get the rotation vector corresponding to this quaternion. | Math/Quat.h | |
FString ToString() |
Get a textual representation of the vector. | Math/Quat.h | |
void ToSwingTwist
(
const TVector< T >& InTwistAxis, |
Get the swing and twist decomposition for a specified axis | Math/Quat.h | |
| Rotate a vector by the inverse of this quaternion. | Math/Quat.h | ||
TVector< T > Vector() |
Convert a rotation into a unit vector facing in its direction. Equivalent to GetForwardVector(). | Math/Quat.h |
Protected
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Calculate tangents between given points | Math/Quat.h | ||
| Error measure (angle) between two quaternions, ranged [0..1]. | Math/Quat.h | ||
| TQuat |
Math/Quat.h | ||
| Bi-Linear Quaternion interpolation. Result is NOT normalized. | Math/Quat.h | ||
| Fast Linear Quaternion Interpolation. Result is NOT normalized. | Math/Quat.h | ||
| Generates the 'smallest' (geodesic) rotation between two vectors of arbitrary length. | Math/Quat.h | ||
| Generates the 'smallest' (geodesic) rotation between two normals (assumed to be unit length). | Math/Quat.h | ||
| Generates the 'smallest' (geodesic) rotation between two vectors of arbitrary length. | Math/Quat.h | ||
| Convert a vector of floating-point Euler angles (in degrees) into a Quaternion. | Math/Quat.h | ||
| Converts to euler angles (in rads) in verse conventions. | Math/Quat.h | ||
static TQuat< T > MakeFromRotationVector
(
const TVector< T >& RotationVector |
Constructs a quaternion corresponding to the rotation vector. | Math/Quat.h | |
| Math/Quat.h | |||
static TQuat< T > MakeFromVectorRegister
(
QuatVectorRegister V |
Math/Quat.h | ||
| Spherical interpolation. Will correct alignment. Result is normalized. | Math/Quat.h | ||
| Spherical interpolation. Will correct alignment. Result is NOT normalized. | Math/Quat.h | ||
static TQuat< T > SlerpFullPath
(
const TQuat< T >& quat1, |
Simpler Slerp that doesn't do any checks for 'shortest distance' etc. | Math/Quat.h | |
static TQuat< T > SlerpFullPath_NotNormalized
(
const TQuat< T >& quat1, |
Simpler Slerp that doesn't do any checks for 'shortest distance' etc. | Math/Quat.h | |
| Given start and end quaternions of quat1 and quat2, and tangents at those points tang1 and tang2, calculate the point at Alpha (between 0 and 1) between them. | Math/Quat.h | ||
| Simpler Squad that doesn't do any checks for 'shortest distance' etc. | Math/Quat.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Gets the result of subtracting a Quaternion to this. | Math/Quat.h | ||
TQuat< T > operator-() |
Negates the quaternion. Note that this represents the same rotation. | Math/Quat.h | |
bool operator!=
(
const TQuat< T >& Q |
Checks whether two quaternions are not identical. | Math/Quat.h | |
| Get the result of scaling this quaternion. | Math/Quat.h | ||
| Multiply this by a matrix. | Math/Quat.h | ||
| Rotate a vector by this quaternion. | Math/Quat.h | ||
| Gets the result of multiplying this by another quaternion (this * Q). | Math/Quat.h | ||
TQuat< T > operator*=
(
const FArg Scale |
Multiply this quaternion by a scaling factor. | Math/Quat.h | |
TQuat< T > operator*=
(
const TQuat< T >& Q |
Multiply this by a quaternion (this = this * Q). | Math/Quat.h | |
TQuat< T > operator/
(
const FArg Scale |
Divide this quaternion by scale. | Math/Quat.h | |
TQuat< T > operator/=
(
const FArg Scale |
Divide this quaternion by scale. | Math/Quat.h | |
T operator|
(
const TQuat< T >& Q |
Calculates dot product of two quaternions. | Math/Quat.h | |
| Gets the result of adding a Quaternion to this. | Math/Quat.h | ||
| Adds to this quaternion. | Math/Quat.h | ||
| Subtracts another quaternion from this. | Math/Quat.h | ||
bool operator==
(
const TQuat< T >& Q |
Checks whether two quaternions are identical. | Math/Quat.h |