Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
InverseRotationMatrix.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"
6#include "Math/UnrealMathUtility.h"
7#include "Math/Plane.h"
8#include "Math/Matrix.h"
9
10namespace UE {
11namespace Math {
12
13/** Inverse Rotation matrix */
14template<typename T>
15struct TInverseRotationMatrix
16 : public TMatrix<T>
17{
18public:
19 /**
20 * Constructor.
21 *
22 * @param Rot rotation
23 */
24 TInverseRotationMatrix(const TRotator<T>& Rot);
25
26 // Conversion to other type.
27 template<typename FArg, TEMPLATE_REQUIRES(!std::is_same_v<T, FArg>)>
28 explicit TInverseRotationMatrix(const TInverseRotationMatrix<FArg>& From) : TMatrix<T>(From) {}
29};
30
31template<typename T>
32FORCEINLINE TInverseRotationMatrix<T>::TInverseRotationMatrix(const TRotator<T>& Rot)
33 : TMatrix<T>(
34 TMatrix<T>( // Yaw
35 TPlane<T>(+FMath::Cos(Rot.Yaw * UE_PI / 180.f), -FMath::Sin(Rot.Yaw * UE_PI / 180.f), 0.0f, 0.0f),
36 TPlane<T>(+FMath::Sin(Rot.Yaw * UE_PI / 180.f), +FMath::Cos(Rot.Yaw * UE_PI / 180.f), 0.0f, 0.0f),
37 TPlane<T>(0.0f, 0.0f, 1.0f, 0.0f),
38 TPlane<T>(0.0f, 0.0f, 0.0f, 1.0f)) *
39 TMatrix<T>( // Pitch
40 TPlane<T>(+FMath::Cos(Rot.Pitch * UE_PI / 180.f), 0.0f, -FMath::Sin(Rot.Pitch * UE_PI / 180.f), 0.0f),
41 TPlane<T>(0.0f, 1.0f, 0.0f, 0.0f),
42 TPlane<T>(+FMath::Sin(Rot.Pitch * UE_PI / 180.f), 0.0f, +FMath::Cos(Rot.Pitch * UE_PI / 180.f), 0.0f),
43 TPlane<T>(0.0f, 0.0f, 0.0f, 1.0f)) *
44 TMatrix<T>( // Roll
45 TPlane<T>(1.0f, 0.0f, 0.0f, 0.0f),
46 TPlane<T>(0.0f, +FMath::Cos(Rot.Roll * UE_PI / 180.f), +FMath::Sin(Rot.Roll * UE_PI / 180.f), 0.0f),
47 TPlane<T>(0.0f, -FMath::Sin(Rot.Roll * UE_PI / 180.f), +FMath::Cos(Rot.Roll * UE_PI / 180.f), 0.0f),
48 TPlane<T>(0.0f, 0.0f, 0.0f, 1.0f))
49 )
50{ }
51
52} // namespace Math
53} // namespace UE
54
55UE_DECLARE_LWC_TYPE(InverseRotationMatrix, 44);
56
57template<> struct TIsUECoreVariant<FInverseRotationMatrix44f> { enum { Value = true }; };
58template<> struct TIsUECoreVariant<FInverseRotationMatrix44d> { enum { Value = true }; };
#define UE_DECLARE_LWC_TYPE(...)
#define FORCEINLINE
Definition Platform.h:644
#define UE_PI
#define TEMPLATE_REQUIRES(...)