FQuat

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

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Math/Quat.h

Include

#include "Math/Quat.h"

Syntax

struct FQuat

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

Variables

Name Description

Public variable

float

 

W

The quaternion's W-component.

Public variable

float

 

X

The quaternion's X-component.

Public variable

float

 

Y

The quaternion's Y-component.

Public variable

float

 

Z

The quaternion's Z-component.

Constructors

Name Description

Public function

FQuat()

Default constructor (no initialization).

Public function

FQuat

(
    EForceInit
)

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

Public function

FQuat

(
    const FMatrix& M
)

Creates and initializes a new quaternion from the given matrix.

Public function

FQuat

(
    const FRotator& R
)

Creates and initializes a new quaternion from the given rotator.

Public function

FQuat

(
    FVector Axis,
    float AngleRad
)

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

Public function

FQuat

(
    float InX,
    float InY,
    float InZ,
    float InW
)

Constructor.

Functions

Name Description

Public function Const

float

 

AngularDistance

(
    const FQuat& Q
)

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

Public function Static

void

 

CalcTangents

(
    const FQuat& PrevP,
    const FQuat& P,
    const FQuat& NextP,
    float Tension,
    FQuat& 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 FQuat& OtherQuat
)

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

Public function Const

bool

 

Equals

(
    const FQuat& Q,
    float Tolerance
)

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

Public function Static

float

 

Error

(
    const FQuat& Q1,
    const FQuat& Q2
)

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

Public function Static

float

 

ErrorAutoNormalize

(
    const FQuat& A,
    const FQuat& B
)

FQuat::Error with auto-normalization.

Public function Const

FVector

 

Euler()

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

Public function Const

FQuat

 

Exp()

Exp should really only be used after Log.

Public function Static

FQuat

 

FastBilerp

(
    const FQuat& P00,
    const FQuat& P10,
    const FQuat& P01,
    const FQuat& P11,
    float FracX,
    float FracY
)

Bi-Linear Quaternion interpolation. Result is NOT normalized.

Public function Static

FQuat

 

FastLerp

(
    const FQuat& A,
    const FQuat& B,
    const float Alpha
)

Fast Linear Quaternion Interpolation. Result is NOT normalized.

Public function Static

FQuat

 

FindBetween

(
    const FVector& Vector1,
    const FVector& Vector2
)

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

Public function Static

FQuat

 

FindBetweenNormals

(
    const FVector& Normal1,
    const FVector& Normal2
)

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

Public function Static

FQuat

 

FindBetweenVectors

(
    const FVector& Vector1,
    const FVector& Vector2
)

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

Public function Const

float

 

GetAngle()

Get the angle of this quaternion

Public function Const

FVector

 

GetAxisX()

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

Public function Const

FVector

 

GetAxisY()

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

Public function Const

FVector

 

GetAxisZ()

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

Public function Const

FVector

 

GetForwardVector()

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

Public function Const

FQuat

 

GetNormalized

(
    float Tolerance
)

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

Public function Const

FVector

 

GetRightVector()

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

Public function Const

FVector

 

GetRotationAxis()

Get the axis of rotation of the Quaternion.

Public function Const

float

 

GetTwistAngle

(
    const FVector& TwistAxis
)

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

Public function Const

FVector

 

GetUpVector()

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

Public function

bool

 

InitFromString

(
    const FString& InSourceString
)

Initialize this FQuat from a FString.

Public function Const

FQuat

 

Inverse()

Public function Const

bool

 

IsIdentity

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

FQuat

 

Log()

Public function Static

FQuat

 

MakeFromEuler

(
    const FVector& Euler
)

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

Public function

bool

 

NetSerialize

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

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

Public function

void

 

Normalize

(
    float Tolerance
)

Normalize this quaternion if it is large enough.

Public function Const

FVector

 

RotateVector

(
    FVector V
)

Rotate a vector by this quaternion.

Public function Const

FRotator

 

Rotator()

Get the FRotator representation of this Quaternion.

Public function

bool

 

Serialize

(
    FArchive& Ar
)

Public function Const

float

 

Size()

Get the length of this quaternion.

Public function Const

float

 

SizeSquared()

Get the length squared of this quaternion.

Public function Static

FQuat

 

Slerp

(
    const FQuat& Quat1,
    const FQuat& Quat2,
    float Slerp
)

Spherical interpolation. Will correct alignment. Result is normalized.

Public function Static

FQuat

 

Slerp_NotNormalized

(
    const FQuat& Quat1,
    const FQuat& Quat2,
    float Slerp
)

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

Public function Static

FQuat

 

SlerpFullPath

(
    const FQuat& quat1,
    const FQuat& quat2,
    float Alpha
)

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

Public function Static

FQuat

 

SlerpFullPath_NotNormalized

(
    const FQuat& quat1,
    const FQuat& quat2,
    float Alpha
)

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

Public function Static

FQuat

 

Squad

(
    const FQuat& quat1,
    const FQuat& tang1,
    const FQuat& quat2,
    const FQuat& tang2,
    float 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

FQuat

 

SquadFullPath

(
    const FQuat& quat1,
    const FQuat& tang1,
    const FQuat& quat2,
    const FQuat& tang2,
    float Alpha
)

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

Public function Const

void

 

ToAxisAndAngle

(
    FVector& Axis,
    float& Angle
)

Get the axis and angle of rotation of this quaternion

: assumes normalized quaternions.

Public function Const

FString

 

ToString()

Get a textual representation of the vector.

Public function Const

void

 

ToSwingTwist

(
    const FVector& InTwistAxis,
    FQuat& OutSwing,
    FQuat& OutTwist
)

Get the swing and twist decomposition for a specified axis

Public function Const

FVector

 

UnrotateVector

(
    FVector V
)

Rotate a vector by the inverse of this quaternion.

Public function Const

FVector

 

Vector()

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

Operators

Name Description

Public function Const

FQuat

 

operator-

(
    const FQuat& Q
)

Gets the result of subtracting a Quaternion to this.

Public function Const

bool

 

operator!=

(
    const FQuat& Q
)

Checks whether two quaternions are not identical.

Public function Const

FQuat

 

operator*

(
    const float Scale
)

Get the result of scaling this quaternion.

Public function Const

FMatrix

 

operator*

(
    const FMatrix& M
)

Multiply this by a matrix.

Public function Const

FVector

 

operator*

(
    const FVector& V
)

Rotate a vector by this quaternion.

Public function Const

FQuat

 

operator*

(
    const FQuat& Q
)

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

Public function

FQuat

 

operator*=

(
    const float Scale
)

Multiply this quaternion by a scaling factor.

Public function

FQuat

 

operator*=

(
    const FQuat& Q
)

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

Public function Const

FQuat

 

operator/

(
    const float Scale
)

Divide this quaternion by scale.

Public function

FQuat

 

operator/=

(
    const float Scale
)

Divide this quaternion by scale.

Public function Const

float

 

operator|

(
    const FQuat& Q
)

Calculates dot product of two quaternions.

Public function Const

FQuat

 

operator+

(
    const FQuat& Q
)

Gets the result of adding a Quaternion to this.

Public function

FQuat

 

operator+=

(
    const FQuat& Q
)

Adds to this quaternion.

Public function

FQuat

 

operator-=

(
    const FQuat& Q
)

Subtracts another quaternion from this.

Public function Const

bool

 

operator==

(
    const FQuat& Q
)

Checks whether two quaternions are identical.

Constants

Name

Description

Identity

Identity quaternion.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss