 # TQuat

## Floating point quaternion that can represent a rotation about an axis in 3-D space.

Inheritance Hierarchy

TQuat TRotation< FReal, 3 >

References

Syntax

template<typename T>
struct TQuat

Remarks

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).

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.

Variables

Name Description

T

W

The quaternion's W-component.

T

X

The quaternion's X-component.

T

Y

The quaternion's Y-component.

T

Z

The quaternion's Z-component.

Constructors

Name Description

TQuat()

Default constructor (no initialization).

TQuat

Creates and initializes a new quaternion, with the W component either 0 or 1.

TQuat

(
T V
)

Initializes all elements to V

TQuat

(
const TRotator< T >& R
)

Creates and initializes a new quaternion from the given rotator.

TQuat

(
const TMatrix< T >& M
)

Creates and initializes a new quaternion from the given matrix.

TQuat

(
const TQuat< FArg >& From
)

Conversion to other type.

TQuat

(
const QuatVectorRegister& V
)

Creates and initializes a new quaternion from the XYZW values in the given VectorRegister4Float.

TQuat

(
TVector< T > Axis,
)

Creates and initializes a new quaternion from the a rotation around the given axis.

TQuat

(
T InX,
T InY,
T InZ,
T InW
)

Constructor.

Functions

Name Description

T

AngularDistance

(
const TQuat< T >& Q
)

Find the angular distance between two rotation quaternions (in radians)

void

CalcTangents

(
const TQuat< T >& PrevP,
const TQuat< T >& P,
const TQuat< T >& NextP,
T Tension,
TQuat< T >& OutTan
)

Calculate tangents between given points

bool

ContainsNaN()

Utility to check if there are any non-finite values (NaN or Inf) in this Quat.

void

DiagnosticCheckNaN

(
const TCHAR* Message
)

void

DiagnosticCheckNaN()

void

EnforceShortestArcWith

(
const TQuat< T >& OtherQuat
)

Enforce that the delta between this Quaternion and another one represents the shortest possible rotation angle

bool

Equals

(
const TQuat< T >& Q,
T Tolerance
)

Checks whether another Quaternion is equal to this, within specified tolerance.

T

Error

(
const TQuat< T >& Q1,
const TQuat< T >& Q2
)

Error measure (angle) between two quaternions, ranged [0..1].

T

ErrorAutoNormalize

(
const TQuat< T >& A,
const TQuat< T >& B
)

TQuat::Error with auto-normalization.

TVector< T >

Euler()

Convert a Quaternion into floating-point Euler angles (in degrees).

TQuat< T >

Exp()

@note Exp should really only be used after Log.

TQuat< T >

FastBilerp

(
const TQuat< T >& P00,
const TQuat< T >& P10,
const TQuat< T >& P01,
const TQuat< T >& P11,
T FracX,
T FracY
)

Bi-Linear Quaternion interpolation. Result is NOT normalized.

TQuat< T >

FastLerp

(
const TQuat< T >& A,
const TQuat< T >& B,
const T Alpha
)

Fast Linear Quaternion Interpolation. Result is NOT normalized.

TQuat< T >

FindBetween

(
const TVector< T >& Vector1,
const TVector< T >& Vector2
)

Generates the 'smallest' (geodesic) rotation between two vectors of arbitrary length.

TQuat< T >

FindBetweenNormals

(
const TVector< T >& Normal1,
const TVector< T >& Normal2
)

Generates the 'smallest' (geodesic) rotation between two normals (assumed to be unit length).

TQuat< T >

FindBetweenVectors

(
const TVector< T >& Vector1,
const TVector< T >& Vector2
)

Generates the 'smallest' (geodesic) rotation between two vectors of arbitrary length.

T

GetAngle()

Get the angle of this quaternion

TVector< T >

GetAxisX()

Get the forward direction (X axis) after it has been rotated by this Quaternion.

TVector< T >

GetAxisY()

Get the right direction (Y axis) after it has been rotated by this Quaternion.

TVector< T >

GetAxisZ()

Get the up direction (Z axis) after it has been rotated by this Quaternion.

TVector< T >

GetForwardVector()

Get the forward direction (X axis) after it has been rotated by this Quaternion.

TQuat< T >

GetNormalized

(
T Tolerance
)

Get a normalized copy of this quaternion. If it is too small, returns an identity quaternion.

TVector< T >

GetRightVector()

Get the right direction (Y axis) after it has been rotated by this Quaternion.

TVector< T >

GetRotationAxis()

Get the axis of rotation of the Quaternion.

T

GetTwistAngle

(
const TVector< T >& TwistAxis
)

Get the twist angle (in radians) for a specified axis

TVector< T >

GetUpVector()

Get the up direction (Z axis) after it has been rotated by this Quaternion.

bool

Identical

(
const TQuat* Q,
const uint32 PortFlags
)

Identical implementation for TQuat properties.

bool

InitFromString

(
const FString& InSourceString
)

Initialize this TQuat from a FString.

TQuat< T >

Inverse()

bool

IsIdentity

(
T Tolerance
)

Checks whether this Quaternion is an Identity Quaternion. Assumes Quaternion tested is normalized.

bool

IsNormalized()

Return true if this quaternion is normalized.

TQuat< T >

Log()

TQuat< T >

MakeFromEuler

(
const TVector< T >& Euler
)

Convert a vector of floating-point Euler angles (in degrees) into a Quaternion.

TQuat< T >

MakeFromRotator

(
const TRotator< T >& R
)

TQuat< T >

MakeFromVectorRegister

(
const QuatVectorRegister& V
)

bool

NetSerialize

(
FArchive& Ar,
UPackageMap* Map,
bool& bOutSuccess
)

Serializes the vector compressed for e.g. network transmission.

void

Normalize

(
T Tolerance
)

Normalize this quaternion if it is large enough.

TVector< T >

RotateVector

(
TVector< T > V
)

Rotate a vector by this quaternion.

TRotator< T ...

Rotator()

Forward declare all explicit specializations (in UnrealMath.cpp)

bool

Serialize

(
FArchive& Ar
)

bool

SerializeFromMismatchedTag

(
FName StructTag,
FArchive& Ar
)

T

Size()

Get the length of this quaternion.

T

SizeSquared()

Get the length squared of this quaternion.

TQuat< T >

Slerp

(
const TQuat< T >& Quat1,
const TQuat< T >& Quat2,
T Slerp
)

Spherical interpolation. Will correct alignment. Result is normalized.

TQuat< T >

Slerp_NotNormalized

(
const TQuat< T >& Quat1,
const TQuat< T >& Quat2,
T Slerp
)

Spherical interpolation. Will correct alignment. Result is NOT normalized.

TQuat< T >

SlerpFullPath

(
const TQuat< T >& quat1,
const TQuat< T >& quat2,
T Alpha
)

Simpler Slerp that doesn't do any checks for 'shortest distance' etc.

TQuat< T >

SlerpFullPath_NotNormalized

(
const TQuat< T >& quat1,
const TQuat< T >& quat2,
T Alpha
)

Simpler Slerp that doesn't do any checks for 'shortest distance' etc.

TQuat< T >

(
const TQuat< T >& quat1,
const TQuat< T >& tang1,
const TQuat< T >& quat2,
const TQuat< T >& tang2,
T Alpha
)

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.

TQuat< T >

(
const TQuat< T >& quat1,
const TQuat< T >& tang1,
const TQuat< T >& quat2,
const TQuat< T >& tang2,
T Alpha
)

Simpler Squad that doesn't do any checks for 'shortest distance' etc.

void

ToAxisAndAngle

(
TVector< T >& Axis,
float& Angle
)

Get the axis and angle of rotation of this quaternion

: assumes normalized quaternions.

void

ToAxisAndAngle

(
TVector< T >& Axis,
double& Angle
)

Get the axis and angle of rotation of this quaternion

: assumes normalized quaternions.

void

ToMatrix

(
TMatrix< T >& Mat
)

Get the TMatrix representation of this Quaternion and store it in Mat

TMatrix< T >

ToMatrix()

Get the TMatrix representation of this Quaternion.

FString

ToString()

Get a textual representation of the vector.

void

ToSwingTwist

(
const TVector< T >& InTwistAxis,
TQuat< T >& OutSwing,
TQuat< T >& OutTwist
)

Get the swing and twist decomposition for a specified axis

TVector< T >

UnrotateVector

(
TVector< T > V
)

Rotate a vector by the inverse of this quaternion.

TVector< T >

Vector()

Convert a rotation into a unit vector facing in its direction.

Operators

Name Description

TQuat< T >

operator-

(
const TQuat< T >& Q
)

Gets the result of subtracting a Quaternion to this.

TQuat< T >

operator-()

Negates the quaternion.

that this represents the same rotation.

bool

operator!=

(
const TQuat< T >& Q
)

Checks whether two quaternions are not identical.

TQuat< T >

operator*

(
const FArg Scale
)

Get the result of scaling this quaternion.

TMatrix< T >

operator*

(
const TMatrix< T >& M
)

Multiply this by a matrix.

TVector< T >

operator*

(
const TVector< T >& V
)

Rotate a vector by this quaternion.

TQuat< T >

operator*

(
const TQuat< T >& Q
)

Gets the result of multiplying this by another quaternion (this * Q).

TQuat< T >

operator*=

(
const FArg Scale
)

Multiply this quaternion by a scaling factor.

TQuat< T >

operator*=

(
const TQuat< T >& Q
)

Multiply this by a quaternion (this = this * Q).

TQuat< T >

operator/

(
const FArg Scale
)

Divide this quaternion by scale.

TQuat< T >

operator/=

(
const FArg Scale
)

Divide this quaternion by scale.

T

operator|

(
const TQuat< T >& Q
)

Calculates dot product of two quaternions.

TQuat< T >

operator+

(
const TQuat< T >& Q
)

Gets the result of adding a Quaternion to this.

TQuat< T >

operator+=

(
const TQuat< T >& Q
)

TQuat< T >

operator-=

(
const TQuat< T >& Q
)

Subtracts another quaternion from this.

bool

operator==

(
const TQuat< T >& Q
)

Checks whether two quaternions are identical.

Typedefs

Name

Description

FReal

Can't have a TEMPLATE_REQUIRES in the declaration because of the forward declarations, so check for allowed types here.

QuatVectorRegister

Constants

Name

Description

Identity

Identity quaternion.