UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RotationTranslationMatrix.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
8#include "Math/Matrix.h"
9
10namespace UE {
11namespace Math {
12
14template<typename T>
16 : public TMatrix<T>
17{
18public:
19 using TMatrix<T>::M;
20
27 [[nodiscard]] TRotationTranslationMatrix(const TRotator<T>& Rot, const TVector<T>& Origin);
28
29 // Conversion to other type.
30 template<typename FArg UE_REQUIRES(!std::is_same_v<T, FArg>)>
32 : TMatrix<T>(From)
33 {
34 }
35
37 [[nodiscard]] static TMatrix<T> Make(const TRotator<T>& Rot, const TVector<T>& Origin)
38 {
39 return TRotationTranslationMatrix(Rot, Origin);
40 }
41};
42
43
44template<typename T>
46{
47#if PLATFORM_ENABLE_VECTORINTRINSICS && (!PLATFORM_CPU_ARM_FAMILY)
48
49 const TVectorRegisterType<T> Angles = MakeVectorRegister(Rot.Pitch, Rot.Yaw, Rot.Roll, 0.0f);
51
52 union { TVectorRegisterType<T> v; T f[4]; } SinAngles, CosAngles;
54
55 const T SP = SinAngles.f[0];
56 const T SY = SinAngles.f[1];
57 const T SR = SinAngles.f[2];
58 const T CP = CosAngles.f[0];
59 const T CY = CosAngles.f[1];
60 const T CR = CosAngles.f[2];
61
62#else
63
64 T SP, SY, SR;
65 T CP, CY, CR;
66 FMath::SinCos(&SP, &CP, (T)FMath::DegreesToRadians(Rot.Pitch));
69
70#endif // PLATFORM_ENABLE_VECTORINTRINSICS
71
72 M[0][0] = CP * CY;
73 M[0][1] = CP * SY;
74 M[0][2] = SP;
75 M[0][3] = 0.f;
76
77 M[1][0] = SR * SP * CY - CR * SY;
78 M[1][1] = SR * SP * SY + CR * CY;
79 M[1][2] = - SR * CP;
80 M[1][3] = 0.f;
81
82 M[2][0] = -( CR * SP * CY + SR * SY );
83 M[2][1] = CY * SR - CR * SP * SY;
84 M[2][2] = CR * CP;
85 M[2][3] = 0.f;
86
87 M[3][0] = Origin.X;
88 M[3][1] = Origin.Y;
89 M[3][2] = Origin.Z;
90 M[3][3] = 1.f;
91}
92
93} // namespace Math
94} // namespace UE
95
97
98template<> struct TIsUECoreVariant<FRotationTranslationMatrix44f> { enum { Value = true }; };
99template<> struct TIsUECoreVariant<FRotationTranslationMatrix44d> { enum { Value = true }; };
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UE_DECLARE_LWC_TYPE(...)
Definition LargeWorldCoordinates.h:27
FORCEINLINE VectorRegister4Float MakeVectorRegister(uint32 X, uint32 Y, uint32 Z, uint32 W)
Definition UnrealMathFPU.h:195
FORCEINLINE void VectorSinCos(VectorRegister4Float *RESTRICT VSinAngles, VectorRegister4Float *RESTRICT VCosAngles, const VectorRegister4Float *RESTRICT VAngles)
Definition UnrealMathFPU.h:2109
FORCEINLINE VectorRegister4Float VectorMultiply(const VectorRegister4Float &Vec1, const VectorRegister4Float &Vec2)
Definition UnrealMathFPU.h:758
typename UE::Math::VectorRegisterPrivate::TVectorRegisterTypeHelper< T >::Type TVectorRegisterType
Definition VectorRegister.h:49
constexpr VectorRegister4Float DEG_TO_RAD
Definition UnrealMathVectorConstants.h.inl:93
Definition AdvancedWidgetsModule.cpp:13
float v
Definition radaudio_mdct.cpp:62
static constexpr UE_FORCEINLINE_HINT auto DegreesToRadians(T const &DegVal) -> decltype(DegVal *(UE_PI/180.f))
Definition UnrealMathUtility.h:871
static constexpr void SinCos(std::decay_t< T > *ScalarSin, std::decay_t< T > *ScalarCos, T Value)
Definition UnrealMathUtility.h:753
Definition IsUECoreType.h:19
@ Value
Definition IsUECoreType.h:20
Definition Matrix.h:43
T M[4][4]
Definition Matrix.h:49
Definition RotationTranslationMatrix.h:17
TRotationTranslationMatrix(const TRotationTranslationMatrix< FArg > &From)
Definition RotationTranslationMatrix.h:31
TRotationTranslationMatrix(const TRotator< T > &Rot, const TVector< T > &Origin)
Definition RotationTranslationMatrix.h:45
static TMatrix< T > Make(const TRotator< T > &Rot, const TVector< T > &Origin)
Definition RotationTranslationMatrix.h:37
Definition Rotator.h:37
Definition Vector.h:51
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
T X
Definition Vector.h:62