UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Math::TRotator< T > Struct Template Reference

#include <Rotator.h>

Public Types

using FReal = T
 

Public Member Functions

UE_FORCEINLINE_HINT void DiagnosticCheckNaN () const
 
UE_FORCEINLINE_HINT void DiagnosticCheckNaN (const TCHAR *Message) const
 
 TRotator ()=default
 
UE_FORCEINLINE_HINT TRotator (T InF)
 
UE_FORCEINLINE_HINT TRotator (T InPitch, T InYaw, T InRoll)
 
UE_FORCEINLINE_HINT TRotator (EForceInit)
 
CORE_API TRotator (const TQuat< T > &Quat)
 
TRotator operator+ (const TRotator< T > &R) const
 
TRotator operator- (const TRotator< T > &R) const
 
template<typename FArg UE_REQUIRES>
UE_FORCEINLINE_HINT TRotator operator* (FArg Scale) const
 
template<typename FArg UE_REQUIRES>
TRotator operator*= (FArg Scale)
 
bool operator== (const TRotator< T > &R) const
 
bool operator!= (const TRotator< T > &V) const
 
TRotator operator+= (const TRotator< T > &R)
 
TRotator operator-= (const TRotator< T > &R)
 
bool IsNearlyZero (T Tolerance=UE_KINDA_SMALL_NUMBER) const
 
bool IsZero () const
 
bool Equals (const TRotator< T > &R, T Tolerance=UE_KINDA_SMALL_NUMBER) const
 
bool EqualsOrientation (const TRotator< T > &R, T Tolerance=UE_KINDA_SMALL_NUMBER) const
 
TRotator Add (T DeltaPitch, T DeltaYaw, T DeltaRoll)
 
CORE_API TRotator GetInverse () const
 
TRotator GridSnap (const TRotator< T > &RotGrid) const
 
CORE_API TVector< T > Vector () const
 
CORE_API TQuat< T > Quaternion () const
 
CORE_API TVector< T > Euler () const
 
CORE_API TVector< T > RotateVector (const UE::Math::TVector< T > &V) const
 
CORE_API TVector< T > UnrotateVector (const UE::Math::TVector< T > &V) const
 
TRotator< T > Clamp () const
 
TRotator< T > GetNormalized () const
 
TRotator< T > GetDenormalized () const
 
GetComponentForAxis (EAxis::Type Axis) const
 
void SetComponentForAxis (EAxis::Type Axis, T Component)
 
void Normalize ()
 
CORE_API void GetWindingAndRemainder (TRotator< T > &Winding, TRotator< T > &Remainder) const
 
GetManhattanDistance (const TRotator< T > &Rotator) const
 
TRotator GetEquivalentRotator () const
 
void SetClosestToMe (TRotator &MakeClosest) const
 
FString ToString () const
 
FString ToCompactString () const
 
bool InitFromString (const FString &InSourceString)
 
bool ContainsNaN () const
 
CORE_API void SerializeCompressed (FArchive &Ar)
 
CORE_API void SerializeCompressedShort (FArchive &Ar)
 
CORE_API bool NetSerialize (FArchive &Ar, class UPackageMap *Map, bool &bOutSuccess)
 
bool Serialize (FArchive &Ar)
 
bool SerializeFromMismatchedTag (FName StructTag, FArchive &Ar)
 
template<typename FArg UE_REQUIRES>
 TRotator (const TRotator< FArg > &From)
 

Static Public Member Functions

staticClampAxis (T Angle)
 
staticNormalizeAxis (T Angle)
 
static uint8 CompressAxisToByte (T Angle)
 
staticDecompressAxisFromByte (uint8 Angle)
 
static uint16 CompressAxisToShort (T Angle)
 
staticDecompressAxisFromShort (uint16 Angle)
 
static CORE_API TRotator MakeFromEuler (const TVector< T > &Euler)
 

Public Attributes

Pitch
 
Yaw
 
Roll
 

Static Public Attributes

static CORE_API const TRotator< T > ZeroRotator
 

Detailed Description

template<typename T>
struct UE::Math::TRotator< T >

Implements a container for rotation information.

All rotation values are stored in degrees.

The angles are interpreted as intrinsic rotations applied in the order Yaw, then Pitch, then Roll. I.e., an object would be rotated first by the specified yaw around its up axis (with positive angles interpreted as clockwise when viewed from above, along -Z), then pitched around its (new) right axis (with positive angles interpreted as 'nose up', i.e. clockwise when viewed along +Y), and then finally rolled around its (final) forward axis (with positive angles interpreted as clockwise rotations when viewed along +X).

Note that these conventions differ from quaternion axis/angle. UE Quat always considers a positive angle to be a left-handed rotation, whereas Rotator treats yaw as left-handed but pitch and roll as right-handed.

Member Typedef Documentation

◆ FReal

template<typename T >
using UE::Math::TRotator< T >::FReal = T

Constructor & Destructor Documentation

◆ TRotator() [1/6]

template<typename T >
UE::Math::TRotator< T >::TRotator ( )
default

Default constructor (no initialization).

◆ TRotator() [2/6]

template<typename T >
UE::Math::TRotator< T >::TRotator ( InF)
inlineexplicit

Constructor

Parameters
InFValue to set all components to.

◆ TRotator() [3/6]

template<typename T >
UE::Math::TRotator< T >::TRotator ( InPitch,
InYaw,
InRoll 
)
inline

Constructor.

Parameters
InPitchPitch in degrees.
InYawYaw in degrees.
InRollRoll in degrees.

◆ TRotator() [4/6]

template<typename T >
UE_FORCEINLINE_HINT UE::Math::TRotator< T >::TRotator ( EForceInit  )
explicit

Constructor.

Parameters
EForceInitForce Init Enum.

◆ TRotator() [5/6]

template<typename T >
UE::Math::TRotator< T >::TRotator ( const TQuat< T > &  Quat)
explicit

Constructor.

Parameters
QuatQuaternion used to specify rotation.

◆ TRotator() [6/6]

template<typename T >
template<typename FArg UE_REQUIRES>
UE::Math::TRotator< T >::TRotator ( const TRotator< FArg > &  From)
inlineexplicit

Member Function Documentation

◆ Add()

template<typename T >
TRotator< T > UE::Math::TRotator< T >::Add ( DeltaPitch,
DeltaYaw,
DeltaRoll 
)
inline

Adds to each component of the rotator.

Parameters
DeltaPitchChange in pitch. (+/-)
DeltaYawChange in yaw. (+/-)
DeltaRollChange in roll. (+/-)
Returns
Copy of rotator after addition.

◆ Clamp()

template<typename T >
UE_FORCEINLINE_HINT TRotator< T > UE::Math::TRotator< T >::Clamp ( ) const

Gets the rotation values so they fall within the range [0,360]

Returns
Clamped version of rotator.

◆ ClampAxis()

template<typename T >
T UE::Math::TRotator< T >::ClampAxis ( Angle)
inlinestatic

Clamps an angle to the range of [0, 360).

Parameters
AngleThe angle to clamp.
Returns
The clamped angle.

◆ CompressAxisToByte()

template<typename T >
UE_FORCEINLINE_HINT uint8 UE::Math::TRotator< T >::CompressAxisToByte ( Angle)
static

Compresses a floating point angle into a byte.

Parameters
AngleThe angle to compress.
Returns
The angle as a byte.

◆ CompressAxisToShort()

template<typename T >
UE_FORCEINLINE_HINT uint16 UE::Math::TRotator< T >::CompressAxisToShort ( Angle)
static

Compress a floating point angle into a word.

Parameters
AngleThe angle to compress.
Returns
The decompressed angle.

◆ ContainsNaN()

template<typename T >
bool UE::Math::TRotator< T >::ContainsNaN ( ) const
inline

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

Returns
true if there are any non-finite values in this Rotator, otherwise false.

◆ DecompressAxisFromByte()

template<typename T >
UE_FORCEINLINE_HINT T UE::Math::TRotator< T >::DecompressAxisFromByte ( uint8  Angle)
static

Decompress a word into a floating point angle.

Parameters
AngleThe word angle.
Returns
The decompressed angle.

◆ DecompressAxisFromShort()

template<typename T >
UE_FORCEINLINE_HINT T UE::Math::TRotator< T >::DecompressAxisFromShort ( uint16  Angle)
static

Decompress a short into a floating point angle.

Parameters
AngleThe word angle.
Returns
The decompressed angle.

◆ DiagnosticCheckNaN() [1/2]

template<typename T >
UE_FORCEINLINE_HINT void UE::Math::TRotator< T >::DiagnosticCheckNaN ( ) const
inline

◆ DiagnosticCheckNaN() [2/2]

template<typename T >
UE_FORCEINLINE_HINT void UE::Math::TRotator< T >::DiagnosticCheckNaN ( const TCHAR Message) const
inline

◆ Equals()

template<typename T >
bool UE::Math::TRotator< T >::Equals ( const TRotator< T > &  R,
Tolerance = UE_KINDA_SMALL_NUMBER 
) const
inline

Checks whether two rotators are equal within specified tolerance, when treated as an orientation. This means that TRotator(0, 0, 360).Equals(TRotator(0,0,0)) is true, because they represent the same final orientation. It can compare only wound rotators (i.e. multiples of 360 degrees) that end up in a same rotation Rotators that represent the same final rotation, but get there via different intermediate rotations aren't equal i.e. TRotator(0, 45, 0).Equals(TRotator(180, 135, 180)) is false

Parameters
RThe other rotator.
ToleranceError Tolerance.
Returns
true if two rotators are equal, within specified tolerance, otherwise false.

◆ EqualsOrientation()

template<typename T >
bool UE::Math::TRotator< T >::EqualsOrientation ( const TRotator< T > &  R,
Tolerance = UE_KINDA_SMALL_NUMBER 
) const

Checks whether two rotators have the same orientation within the specified tolerance, without requiring similar angles or wound multiples of 360. Unlike Equals(), it can compare Rotators that represent the same final orientation, but get there via different intermediate rotations. i.e. If we compare two rotators with different angles, but same orientation like so: A = TRotator(0, 45, 0) B = TRotator(180, 135, 180) Then A.EqualsOrientation(B) would be TRUE while A.Equals(B) would be FALSE

Parameters
RThe other rotator.
ToleranceError Tolerance.
Returns
true if two rotators are equal, within specified tolerance, otherwise false.

◆ Euler()

template<typename T >
UE::Math::TVector< T > UE::Math::TRotator< T >::Euler ( ) const

Convert a Rotator into floating-point Euler angles (in degrees). Rotator now stored in degrees.

Returns
Rotation as a Euler angle vector.

◆ GetComponentForAxis()

template<typename T >
T UE::Math::TRotator< T >::GetComponentForAxis ( EAxis::Type  Axis) const
inline

Get a specific component of the vector, given a specific axis by enum

◆ GetDenormalized()

template<typename T >
TRotator< T > UE::Math::TRotator< T >::GetDenormalized ( ) const
inline

Create a copy of this rotator and denormalize, clamping each axis to 0 - 360.

Returns
Denormalized copy of this rotator

◆ GetEquivalentRotator()

template<typename T >
UE_FORCEINLINE_HINT TRotator< T > UE::Math::TRotator< T >::GetEquivalentRotator ( ) const

Return a Rotator that has the same rotation but has different degree values for Yaw, Pitch, and Roll. This rotator should be within -180,180 range,

Returns
A Rotator with the same rotation but different degrees.

◆ GetInverse()

template<typename T >
UE::Math::TRotator< T > UE::Math::TRotator< T >::GetInverse ( ) const

Returns the inverse of the rotator.

◆ GetManhattanDistance()

template<typename T >
UE_FORCEINLINE_HINT T UE::Math::TRotator< T >::GetManhattanDistance ( const TRotator< T > &  Rotator) const

Return the manhattan distance in degrees between this Rotator and the passed in one.

Parameters
Rotator[In]the Rotator we are comparing with.
Returns
Distance(Manhattan) between the two rotators.

◆ GetNormalized()

template<typename T >
TRotator< T > UE::Math::TRotator< T >::GetNormalized ( ) const
inline

Create a copy of this rotator and normalize, removes all winding and creates the "shortest route" rotation.

Returns
Normalized copy of this rotator

◆ GetWindingAndRemainder()

template<typename T >
void UE::Math::TRotator< T >::GetWindingAndRemainder ( TRotator< T > &  Winding,
TRotator< T > &  Remainder 
) const

Decompose this Rotator into a Winding part (multiples of 360) and a Remainder part. Remainder will always be in [-180, 180] range.

Parameters
Winding[Out]the Winding part of this Rotator
Remainder[Out]the Remainder

◆ GridSnap()

template<typename T >
TRotator< T > UE::Math::TRotator< T >::GridSnap ( const TRotator< T > &  RotGrid) const
inline

Get the rotation, snapped to specified degree segments.

Parameters
RotGridA Rotator specifying how to snap each component.
Returns
Snapped version of rotation.

◆ InitFromString()

template<typename T >
bool UE::Math::TRotator< T >::InitFromString ( const FString &  InSourceString)
inline

Initialize this Rotator based on an FString. The String is expected to contain P=, Y=, R=. The TRotator will be bogus when InitFromString returns false.

Parameters
InSourceStringFString containing the rotator values.
Returns
true if the P,Y,R values were read successfully; false otherwise.

◆ IsNearlyZero()

template<typename T >
bool UE::Math::TRotator< T >::IsNearlyZero ( Tolerance = UE_KINDA_SMALL_NUMBER) const
inline

Checks whether rotator is nearly zero within specified tolerance, when treated as an orientation. This means that TRotator(0, 0, 360) is "zero", because it is the same final orientation as the zero rotator.

Parameters
ToleranceError Tolerance.
Returns
true if rotator is nearly zero, within specified tolerance, otherwise false.

◆ IsZero()

template<typename T >
UE_FORCEINLINE_HINT bool UE::Math::TRotator< T >::IsZero ( ) const

Checks whether this has exactly zero rotation, when treated as an orientation. This means that TRotator(0, 0, 360) is "zero", because it is the same final orientation as the zero rotator.

Returns
true if this has exactly zero rotation, otherwise false.

◆ MakeFromEuler()

template<typename T >
UE::Math::TRotator< T > UE::Math::TRotator< T >::MakeFromEuler ( const TVector< T > &  Euler)
static

Convert a vector of floating-point Euler angles (in degrees) into a Rotator. Rotator now stored in degrees

Parameters
EulerEuler angle vector.
Returns
A rotator from a Euler angle.

◆ NetSerialize()

template<typename T >
bool UE::Math::TRotator< T >::NetSerialize ( FArchive Ar,
class UPackageMap Map,
bool bOutSuccess 
)

◆ Normalize()

template<typename T >
void UE::Math::TRotator< T >::Normalize ( )
inline

In-place normalize, removes all winding and creates the "shortest route" rotation.

◆ NormalizeAxis()

template<typename T >
T UE::Math::TRotator< T >::NormalizeAxis ( Angle)
inlinestatic

Clamps an angle to the range of (-180, 180].

Parameters
AngleThe Angle to clamp.
Returns
The clamped angle.

◆ operator!=()

template<typename T >
UE_FORCEINLINE_HINT bool UE::Math::TRotator< T >::operator!= ( const TRotator< T > &  V) const

Checks whether two rotators are different.

Parameters
VThe other rotator.
Returns
true if two rotators are different, otherwise false.

◆ operator*()

template<typename T >
template<typename FArg UE_REQUIRES>
UE_FORCEINLINE_HINT TRotator UE::Math::TRotator< T >::operator* ( FArg  Scale) const
inline

Get the result of scaling this rotator.

Parameters
ScaleThe scaling factor.
Returns
The result of scaling.

◆ operator*=()

template<typename T >
template<typename FArg UE_REQUIRES>
TRotator UE::Math::TRotator< T >::operator*= ( FArg  Scale)
inline

Multiply this rotator by a scaling factor.

Parameters
ScaleThe scaling factor.
Returns
Copy of the rotator after scaling.

◆ operator+()

template<typename T >
UE_FORCEINLINE_HINT TRotator< T > UE::Math::TRotator< T >::operator+ ( const TRotator< T > &  R) const

Get the result of adding a rotator to this.

Parameters
RThe other rotator.
Returns
The result of adding a rotator to this.

◆ operator+=()

template<typename T >
TRotator< T > UE::Math::TRotator< T >::operator+= ( const TRotator< T > &  R)
inline

Adds another rotator to this.

Parameters
RThe other rotator.
Returns
Copy of rotator after addition.

◆ operator-()

template<typename T >
UE_FORCEINLINE_HINT TRotator< T > UE::Math::TRotator< T >::operator- ( const TRotator< T > &  R) const

Get the result of subtracting a rotator from this.

Parameters
RThe other rotator.
Returns
The result of subtracting a rotator from this.

◆ operator-=()

template<typename T >
TRotator< T > UE::Math::TRotator< T >::operator-= ( const TRotator< T > &  R)
inline

Subtracts another rotator from this.

Parameters
RThe other rotator.
Returns
Copy of rotator after subtraction.

◆ operator==()

template<typename T >
UE_FORCEINLINE_HINT bool UE::Math::TRotator< T >::operator== ( const TRotator< T > &  R) const

Checks whether two rotators are identical. This checks each component for exact equality.

Parameters
RThe other rotator.
Returns
true if two rotators are identical, otherwise false.
See also
Equals()

◆ Quaternion()

template<typename T >
CORE_API TQuat< T > UE::Math::TRotator< T >::Quaternion ( ) const

Get Rotation as a quaternion.

Returns
Rotation as a quaternion.

◆ RotateVector()

template<typename T >
UE::Math::TVector< T > UE::Math::TRotator< T >::RotateVector ( const UE::Math::TVector< T > &  V) const

Rotate a vector rotated by this rotator.

Parameters
VThe vector to rotate.
Returns
The rotated vector.

◆ Serialize()

template<typename T >
bool UE::Math::TRotator< T >::Serialize ( FArchive Ar)
inline

◆ SerializeCompressed()

template<typename T >
void UE::Math::TRotator< T >::SerializeCompressed ( FArchive Ar)

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

Parameters
ArArchive to serialize to/ from

◆ SerializeCompressedShort()

template<typename T >
void UE::Math::TRotator< T >::SerializeCompressedShort ( FArchive Ar)

Serializes the rotator compressed for e.g. network transmission (use shorts though).

Parameters
ArArchive to serialize to/ from

◆ SerializeFromMismatchedTag()

template<typename T >
bool UE::Math::TRotator< T >::SerializeFromMismatchedTag ( FName  StructTag,
FArchive Ar 
)
inline

◆ SetClosestToMe()

template<typename T >
void UE::Math::TRotator< T >::SetClosestToMe ( TRotator< T > &  MakeClosest) const
inline

Modify if necessary the passed in rotator to be the closest rotator to it based upon it's equivalent. This Rotator should be within (-180, 180], usually just constructed from a Matrix or a Quaternion.

Parameters
MakeClosest[In/Out]the Rotator we want to make closest to us. Should be between (-180, 180]. This Rotator may change if we need to use different degree values to make it closer.

◆ SetComponentForAxis()

template<typename T >
void UE::Math::TRotator< T >::SetComponentForAxis ( EAxis::Type  Axis,
Component 
)
inline

Set a specified componet of the vector, given a specific axis by enum

◆ ToCompactString()

template<typename T >
FString UE::Math::TRotator< T >::ToCompactString ( ) const
inline

Get a short textural representation of this vector, for compact readable logging.

◆ ToString()

template<typename T >
UE_FORCEINLINE_HINT FString UE::Math::TRotator< T >::ToString ( ) const

Get a textual representation of the vector.

Returns
Text describing the vector.

◆ UnrotateVector()

template<typename T >
UE::Math::TVector< T > UE::Math::TRotator< T >::UnrotateVector ( const UE::Math::TVector< T > &  V) const

Returns the vector rotated by the inverse of this rotator.

Parameters
VThe vector to rotate.
Returns
The rotated vector.

◆ Vector()

template<typename T >
UE::Math::TVector< T > UE::Math::TRotator< T >::Vector ( ) const

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

Returns
Rotation as a unit direction vector.

Member Data Documentation

◆ Pitch

template<typename T >
T UE::Math::TRotator< T >::Pitch

Rotation around the right axis (around Y axis), Looking up and down (0=Straight Ahead, +Up, -Down)

◆ Roll

template<typename T >
T UE::Math::TRotator< T >::Roll

Rotation around the forward axis (around X axis), Tilting your head, (0=Straight, +Clockwise, -CCW)

◆ Yaw

template<typename T >
T UE::Math::TRotator< T >::Yaw

Rotation around the up axis (around Z axis), Turning around (0=Forward, +Right, -Left)

◆ ZeroRotator

template<typename T >
CORE_API const TRotator<T> UE::Math::TRotator< T >::ZeroRotator
static

A rotator of zero degrees on each axis.


The documentation for this struct was generated from the following files: