TQuat

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

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/CoreFwd.h

Include

#include "CoreFwd.h"

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

Public variable

T

 

W

The quaternion's W-component.

Public variable

T

 

X

The quaternion's X-component.

Public variable

T

 

Y

The quaternion's Y-component.

Public variable

T

 

Z

The quaternion's Z-component.

Constructors

Name Description

Public function

TQuat()

Default constructor (no initialization).

Public function

TQuat

(
    EForceInit
)

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

Public function

TQuat

(
    T V
)

Initializes all elements to V

Public function

TQuat

(
    const TRotator< T >& R
)

Creates and initializes a new quaternion from the given rotator.

Public function

TQuat

(
    const TMatrix< T >& M
)

Creates and initializes a new quaternion from the given matrix.

Public function

TQuat

(
    const TQuat< FArg >& From
)

Conversion to other type.

Protected function

TQuat

(
    const QuatVectorRegister& V
)

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

Public function

TQuat

(
    TVector< T > Axis,
    T AngleRad
)

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

Public function

TQuat

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

Constructor.

Functions

Name Description

Public function Const

T

 

AngularDistance

(
    const TQuat< T >& Q
)

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

Public function Static

void

 

CalcTangents

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

Calculate tangents between given points

Public function Const

bool

 

ContainsNaN()

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

Public function Const

void

 

DiagnosticCheckNaN

(
    const TCHAR* Message
)

Public function Const

void

 

DiagnosticCheckNaN()

Public function

void

 

EnforceShortestArcWith

(
    const TQuat< T >& OtherQuat
)

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

Public function Const

bool

 

Equals

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

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

Public function Static

T

 

Error

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

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

Public function Static

T

 

ErrorAutoNormalize

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

TQuat::Error with auto-normalization.

Public function Const

TVector< T >

 

Euler()

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

Public function Const

TQuat< T >

 

Exp()

@note Exp should really only be used after Log.

Public function Static

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.

Public function Static

TQuat< T >

 

FastLerp

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

Fast Linear Quaternion Interpolation. Result is NOT normalized.

Public function Static

TQuat< T >

 

FindBetween

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

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

Public function Static

TQuat< T >

 

FindBetweenNormals

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

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

Public function Static

TQuat< T >

 

FindBetweenVectors

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

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

Public function Const

T

 

GetAngle()

Get the angle of this quaternion

Public function Const

TVector< T >

 

GetAxisX()

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

Public function Const

TVector< T >

 

GetAxisY()

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

Public function Const

TVector< T >

 

GetAxisZ()

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

Public function Const

TVector< T >

 

GetForwardVector()

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

Public function Const

TQuat< T >

 

GetNormalized

(
    T Tolerance
)

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

Public function Const

TVector< T >

 

GetRightVector()

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

Public function Const

TVector< T >

 

GetRotationAxis()

Get the axis of rotation of the Quaternion.

Public function Const

T

 

GetTwistAngle

(
    const TVector< T >& TwistAxis
)

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

Public function Const

TVector< T >

 

GetUpVector()

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

Public function Const

bool

 

Identical

(
    const TQuat* Q,
    const uint32 PortFlags
)

Identical implementation for TQuat properties.

Public function

bool

 

InitFromString

(
    const FString& InSourceString
)

Initialize this TQuat from a FString.

Public function Const

TQuat< T >

 

Inverse()

Public function Const

bool

 

IsIdentity

(
    T Tolerance
)

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

Public function Const

bool

 

IsNormalized()

Return true if this quaternion is normalized.

Public function Const

TQuat< T >

 

Log()

Public function Static

TQuat< T >

 

MakeFromEuler

(
    const TVector< T >& Euler
)

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

Public function Static

TQuat< T >

 

MakeFromRotator

(
    const TRotator< T >& R
)

Public function Static

TQuat< T >

 

MakeFromVectorRegister

(
    const QuatVectorRegister& V
)

Public function

bool

 

NetSerialize

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

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

Public function

void

 

Normalize

(
    T Tolerance
)

Normalize this quaternion if it is large enough.

Public function Const

TVector< T >

 

RotateVector

(
    TVector< T > V
)

Rotate a vector by this quaternion.

Public function Const

TRotator< T ...

 

Rotator()

Forward declare all explicit specializations (in UnrealMath.cpp)

Public function

bool

 

Serialize

(
    FArchive& Ar
)

Public function

bool

 

SerializeFromMismatchedTag

(
    FName StructTag,
    FArchive& Ar
)

Public function Const

T

 

Size()

Get the length of this quaternion.

Public function Const

T

 

SizeSquared()

Get the length squared of this quaternion.

Public function Static

TQuat< T >

 

Slerp

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

Spherical interpolation. Will correct alignment. Result is normalized.

Public function Static

TQuat< T >

 

Slerp_NotNormalized

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

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

Public function Static

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.

Public function Static

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.

Public function Static

TQuat< T >

 

Squad

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

Public function Static

TQuat< T >

 

SquadFullPath

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

Public function Const

void

 

ToAxisAndAngle

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

Get the axis and angle of rotation of this quaternion

: assumes normalized quaternions.

Public function Const

void

 

ToAxisAndAngle

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

Get the axis and angle of rotation of this quaternion

: assumes normalized quaternions.

Public function Const

void

 

ToMatrix

(
    TMatrix< T >& Mat
)

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

Public function Const

TMatrix< T >

 

ToMatrix()

Get the TMatrix representation of this Quaternion.

Public function Const

FString

 

ToString()

Get a textual representation of the vector.

Public function Const

void

 

ToSwingTwist

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

Get the swing and twist decomposition for a specified axis

Public function Const

TVector< T >

 

UnrotateVector

(
    TVector< T > V
)

Rotate a vector by the inverse of this quaternion.

Public function Const

TVector< T >

 

Vector()

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

Operators

Name Description

Public function Const

TQuat< T >

 

operator-

(
    const TQuat< T >& Q
)

Gets the result of subtracting a Quaternion to this.

Public function Const

TQuat< T >

 

operator-()

Negates the quaternion.

that this represents the same rotation.

Public function Const

bool

 

operator!=

(
    const TQuat< T >& Q
)

Checks whether two quaternions are not identical.

Public function Const

TQuat< T >

 

operator*

(
    const FArg Scale
)

Get the result of scaling this quaternion.

Public function Const

TMatrix< T >

 

operator*

(
    const TMatrix< T >& M
)

Multiply this by a matrix.

Public function Const

TVector< T >

 

operator*

(
    const TVector< T >& V
)

Rotate a vector by this quaternion.

Public function Const

TQuat< T >

 

operator*

(
    const TQuat< T >& Q
)

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

Public function

TQuat< T >

 

operator*=

(
    const FArg Scale
)

Multiply this quaternion by a scaling factor.

Public function

TQuat< T >

 

operator*=

(
    const TQuat< T >& Q
)

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

Public function Const

TQuat< T >

 

operator/

(
    const FArg Scale
)

Divide this quaternion by scale.

Public function

TQuat< T >

 

operator/=

(
    const FArg Scale
)

Divide this quaternion by scale.

Public function Const

T

 

operator|

(
    const TQuat< T >& Q
)

Calculates dot product of two quaternions.

Public function Const

TQuat< T >

 

operator+

(
    const TQuat< T >& Q
)

Gets the result of adding a Quaternion to this.

Public function

TQuat< T >

 

operator+=

(
    const TQuat< T >& Q
)

Adds to this quaternion.

Public function

TQuat< T >

 

operator-=

(
    const TQuat< T >& Q
)

Subtracts another quaternion from this.

Public function Const

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.