UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ScaleRotationTranslationMatrix.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"
7#include "Math/Matrix.h"
8
9
10namespace UE {
11namespace Math {
12
14template<typename T>
16 : public TMatrix<T>
17{
18public:
19 using TMatrix<T>::M;
20
29
30 // Conversion to other type.
31 template<typename FArg UE_REQUIRES(!std::is_same_v<T, FArg>)>
36};
37
38namespace
39{
40 template<typename T>
41 void GetSinCos(T& S, T& C, T Degrees)
42 {
43 if (Degrees == 0.f)
44 {
45 S = 0.f;
46 C = 1.f;
47 }
48 else if (Degrees == 90.f)
49 {
50 S = 1.f;
51 C = 0.f;
52 }
53 else if (Degrees == 180.f)
54 {
55 S = 0.f;
56 C = -1.f;
57 }
58 else if (Degrees == 270.f)
59 {
60 S = -1.f;
61 C = 0.f;
62 }
63 else
64 {
66 }
67 }
68}
69
70template<typename T>
72{
73 T SP, SY, SR;
74 T CP, CY, CR;
75 GetSinCos(SP, CP, (T)Rot.Pitch);
76 GetSinCos(SY, CY, (T)Rot.Yaw);
77 GetSinCos(SR, CR, (T)Rot.Roll);
78
79 M[0][0] = (CP * CY) * Scale.X;
80 M[0][1] = (CP * SY) * Scale.X;
81 M[0][2] = (SP) * Scale.X;
82 M[0][3] = 0.f;
83
84 M[1][0] = (SR * SP * CY - CR * SY) * Scale.Y;
85 M[1][1] = (SR * SP * SY + CR * CY) * Scale.Y;
86 M[1][2] = (- SR * CP) * Scale.Y;
87 M[1][3] = 0.f;
88
89 M[2][0] = ( -( CR * SP * CY + SR * SY ) ) * Scale.Z;
90 M[2][1] = (CY * SR - CR * SP * SY) * Scale.Z;
91 M[2][2] = (CR * CP) * Scale.Z;
92 M[2][3] = 0.f;
93
94 M[3][0] = Origin.X;
95 M[3][1] = Origin.Y;
96 M[3][2] = Origin.Z;
97 M[3][3] = 1.f;
98}
99
100} // namespace Math
101} // namespace UE
102
104
105template<> struct TIsUECoreVariant<FScaleRotationTranslationMatrix44f> { enum { Value = true }; };
106template<> struct TIsUECoreVariant<FScaleRotationTranslationMatrix44d> { 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
Definition AdvancedWidgetsModule.cpp:13
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 Rotator.h:37
Definition ScaleRotationTranslationMatrix.h:17
TScaleRotationTranslationMatrix(const TScaleRotationTranslationMatrix< FArg > &From)
Definition ScaleRotationTranslationMatrix.h:32
TScaleRotationTranslationMatrix(const TVector< T > &Scale, const TRotator< T > &Rot, const TVector< T > &Origin)
Definition ScaleRotationTranslationMatrix.h:71
Definition Vector.h:51
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
T X
Definition Vector.h:62