Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
RotationAboutPointMatrix.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/Vector.h"
7#include "Math/Matrix.h"
8#include "Math/Quat.h"
9#include "Math/RotationTranslationMatrix.h"
10
11namespace UE {
12namespace Math {
13
14/** Rotates about an Origin point. */
15template<typename T>
17 : public TRotationTranslationMatrix<T>
18{
19public:
20 using TRotationTranslationMatrix<T>::M;
21
22 /**
23 * Constructor.
24 *
25 * @param Rot rotation
26 * @param Origin about which to rotate.
27 */
28 TRotationAboutPointMatrix(const TRotator<T>& Rot, const TVector<T>& Origin);
29
30 // Conversion to other type.
31 template<typename FArg, TEMPLATE_REQUIRES(!std::is_same_v<T, FArg>)>
33
34 /** Matrix factory. Return an TMatrix<T> so we don't have type conversion issues in expressions. */
35 static TMatrix<T> Make(const TRotator<T>& Rot, const TVector<T>& Origin)
36 {
38 }
39
40 /** Matrix factory. Return an TMatrix<T> so we don't have type conversion issues in expressions. */
41 static TMatrix<T> Make(const TQuat<T>& Rot, const TVector<T>& Origin)
42 {
44 }
45};
46
47template<typename T>
48FORCEINLINE TRotationAboutPointMatrix<T>::TRotationAboutPointMatrix(const TRotator<T>& Rot, const TVector<T>& Origin)
50{
51 // FRotationTranslationMatrix generates R * T.
52 // We need -T * R * T, so prepend that translation:
53 TVector<T> XAxis(M[0][0], M[1][0], M[2][0]);
54 TVector<T> YAxis(M[0][1], M[1][1], M[2][1]);
55 TVector<T> ZAxis(M[0][2], M[1][2], M[2][2]);
56
57 M[3][0] -= XAxis | Origin;
58 M[3][1] -= YAxis | Origin;
59 M[3][2] -= ZAxis | Origin;
60}
61
62} // namespace Math
63} // namespace UE
64
65UE_DECLARE_LWC_TYPE(RotationAboutPointMatrix, 44);
66
67template<> struct TIsUECoreVariant<FRotationAboutPointMatrix44f> { enum { Value = true }; };
68template<> struct TIsUECoreVariant<FRotationAboutPointMatrix44d> { enum { Value = true }; };
#define UE_DECLARE_LWC_TYPE(...)
#define FORCEINLINE
Definition Platform.h:644
#define TEMPLATE_REQUIRES(...)
Definition Vector.h:40
Definition json.hpp:4518
static TMatrix< T > Make(const TRotator< T > &Rot, const TVector< T > &Origin)
TRotationAboutPointMatrix(const TRotationAboutPointMatrix< FArg > &From)
static TMatrix< T > Make(const TQuat< T > &Rot, const TVector< T > &Origin)
TRotationAboutPointMatrix(const TRotator< T > &Rot, const TVector< T > &Origin)