UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
QuatRotationTranslationMatrix.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/Vector.h"
8#include "Math/Matrix.h"
9#include "Math/Quat.h"
10
11namespace UE {
12namespace Math {
13
15template <typename T>
17 : public TMatrix<T>
18{
19public:
20 using TMatrix<T>::M;
21
27 TQuatRotationTranslationMatrix(const TQuat<T>& Q, const TVector<T>& Origin);
28
29 // Conversion to other type.
30 template<typename FArg UE_REQUIRES(!std::is_same_v<T, FArg>)>
35
37 static TMatrix<T> Make(const TQuat<T>& Q, const TVector<T>& Origin)
38 {
39 return TQuatRotationTranslationMatrix<T>(Q, Origin);
40 }
41};
42
43
45template<typename T>
48{
49public:
51
57 : TQuatRotationTranslationMatrix<T>(Q, TVector<T>::ZeroVector)
58 {
59 }
60
61 // Conversion to other type.
62 template<typename FArg UE_REQUIRES(!std::is_same_v<T, FArg>)>
67
69 static TMatrix<T> Make(const TQuat<T>& Q)
70 {
71 return TQuatRotationMatrix<T>(Q);
72 }
73};
74
75
76template<typename T>
78{
79#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) && WITH_EDITORONLY_DATA
80 // Make sure Quaternion is normalized
81 check( Q.IsNormalized() );
82#endif
83 const T x2 = Q.X + Q.X; const T y2 = Q.Y + Q.Y; const T z2 = Q.Z + Q.Z;
84 const T xx = Q.X * x2; const T xy = Q.X * y2; const T xz = Q.X * z2;
85 const T yy = Q.Y * y2; const T yz = Q.Y * z2; const T zz = Q.Z * z2;
86 const T wx = Q.W * x2; const T wy = Q.W * y2; const T wz = Q.W * z2;
87
88 M[0][0] = 1.0f - (yy + zz); M[1][0] = xy - wz; M[2][0] = xz + wy; M[3][0] = Origin.X;
89 M[0][1] = xy + wz; M[1][1] = 1.0f - (xx + zz); M[2][1] = yz - wx; M[3][1] = Origin.Y;
90 M[0][2] = xz - wy; M[1][2] = yz + wx; M[2][2] = 1.0f - (xx + yy); M[3][2] = Origin.Z;
91 M[0][3] = 0.0f; M[1][3] = 0.0f; M[2][3] = 0.0f; M[3][3] = 1.0f;
92}
93
94} // namespace Math
95} // namespace UE
96
99
100template<> struct TIsUECoreVariant<FQuatRotationTranslationMatrix44f> { enum { Value = true }; };
101template<> struct TIsUECoreVariant<FQuatRotationTranslationMatrix44d> { enum { Value = true }; };
102template<> struct TIsUECoreVariant<FQuatRotationMatrix44f> { enum { Value = true }; };
103template<> struct TIsUECoreVariant<FQuatRotationMatrix44d> { enum { Value = true }; };
#define check(expr)
Definition AssertionMacros.h:314
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
Definition IsUECoreType.h:19
@ Value
Definition IsUECoreType.h:20
Definition Matrix.h:43
T M[4][4]
Definition Matrix.h:49
Definition QuatRotationTranslationMatrix.h:48
TQuatRotationMatrix(const TQuatRotationMatrix< FArg > &From)
Definition QuatRotationTranslationMatrix.h:63
TQuatRotationMatrix(const TQuat< T > &Q)
Definition QuatRotationTranslationMatrix.h:56
static TMatrix< T > Make(const TQuat< T > &Q)
Definition QuatRotationTranslationMatrix.h:69
Definition QuatRotationTranslationMatrix.h:18
static TMatrix< T > Make(const TQuat< T > &Q, const TVector< T > &Origin)
Definition QuatRotationTranslationMatrix.h:37
TQuatRotationTranslationMatrix(const TQuatRotationTranslationMatrix< FArg > &From)
Definition QuatRotationTranslationMatrix.h:31
TQuatRotationTranslationMatrix(const TQuat< T > &Q, const TVector< T > &Origin)
Definition QuatRotationTranslationMatrix.h:77
Definition Quat.h:39
T W
Definition Quat.h:58
bool IsNormalized() const
Definition Quat.h:1149
T Y
Definition Quat.h:52
T Z
Definition Quat.h:55
T X
Definition Quat.h:49
Definition Vector.h:51
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
T X
Definition Vector.h:62