UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DualQuat.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/Quat.h"
9#include "Math/Transform.h"
10
12namespace UE
13{
14namespace Math
15{
16
17template<typename T>
19{
20public:
21 using FReal = T;
22
27
28 // Constructors
30 : R(InR)
31 , D(InD)
32 {}
33
35 {
36 TVector<T> V = Transform.GetTranslation()*0.5f;
37 *this = TDualQuat<T>(TQuat<T>(0, 0, 0, 1), TQuat<T>(V.X, V.Y, V.Z, 0.f)) * TDualQuat<T>(Transform.GetRotation(), TQuat<T>(0, 0, 0, 0));
38 }
39
40 // Conversion to other type.
41 template<typename FArg UE_REQUIRES(!std::is_same_v<T, FArg>)>
42 [[nodiscard]] explicit TDualQuat(const TDualQuat<FArg>& From)
43 : TDualQuat<T>(TQuat<T>(From.R), TQuat<T>(From.D))
44 {
45 }
46
49 {
50 return{ R + B.R, D + B.D };
51 }
52
55 {
56 return{ R*B.R, D*B.R + B.D*R };
57 }
58
60 [[nodiscard]] TDualQuat<T> operator*(const T S) const
61 {
62 return{ R*S, D*S };
63 }
64
67 {
68 T MinV = 1.0f / FMath::Sqrt(R | R);
69 return{ R*MinV, D*MinV };
70 }
71
74 {
75 TQuat<T> TQ = D*TQuat<T>(-R.X, -R.Y, -R.Z, R.W);
76 return TTransform<T>(R, TVector<T>(TQ.X, TQ.Y, TQ.Z)*2.0f, Scale);
77 }
78};
79
80} // namespace UE::Math
81} // namespace UE
82
84
85template<> struct TIsUECoreVariant<FDualQuat4f> { enum { Value = true }; };
86template<> struct TIsUECoreVariant<FDualQuat4d> { 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
Definition IsUECoreType.h:19
@ Value
Definition IsUECoreType.h:20
Definition DualQuat.h:19
TDualQuat< T > operator+(const TDualQuat< T > &B) const
Definition DualQuat.h:48
TDualQuat(const TQuat< T > &InR, const TQuat< T > &InD)
Definition DualQuat.h:29
TDualQuat(const TTransform< T > &Transform)
Definition DualQuat.h:34
TQuat< T > D
Definition DualQuat.h:26
TTransform< T > AsFTransform(TVector< T > Scale=TVector< T >(1.0f, 1.0f, 1.0f)) const
Definition DualQuat.h:73
T FReal
Definition DualQuat.h:21
TQuat< T > R
Definition DualQuat.h:24
TDualQuat< T > operator*(const TDualQuat< T > &B) const
Definition DualQuat.h:54
TDualQuat< T > operator*(const T S) const
Definition DualQuat.h:60
TDualQuat(const TDualQuat< FArg > &From)
Definition DualQuat.h:42
TDualQuat< T > Normalized() const
Definition DualQuat.h:66
Definition Quat.h:39
Definition TransformNonVectorized.h:39
Definition Vector.h:51
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
T X
Definition Vector.h:62