Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
MirrorMatrix.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/Plane.h"
7#include "Math/Matrix.h"
8
9namespace UE {
10namespace Math {
11
12 /**
13 * Mirrors a point about an arbitrary plane
14 */
15template<typename T>
16struct TMirrorMatrix
17 : public TMatrix<T>
18{
19public:
20
21 /**
22 * Constructor. Updated for the fact that our FPlane uses Ax+By+Cz=D.
23 *
24 * @param Plane source plane for mirroring (assumed normalized)
25 */
26 TMirrorMatrix( const TPlane<T>& Plane );
27
28 // Conversion to other type.
29 template<typename FArg, TEMPLATE_REQUIRES(!std::is_same_v<T, FArg>)>
30 explicit TMirrorMatrix(const TMirrorMatrix<FArg>& From) : TMatrix<T>(From) {}
31};
32
33template<typename T>
34FORCEINLINE TMirrorMatrix<T>::TMirrorMatrix( const TPlane<T>& Plane ) :
35FMatrix(
36 TPlane<T>( -2.f*Plane.X*Plane.X + 1.f, -2.f*Plane.Y*Plane.X, -2.f*Plane.Z*Plane.X, 0.f ),
37 TPlane<T>( -2.f*Plane.X*Plane.Y, -2.f*Plane.Y*Plane.Y + 1.f, -2.f*Plane.Z*Plane.Y, 0.f ),
38 TPlane<T>( -2.f*Plane.X*Plane.Z, -2.f*Plane.Y*Plane.Z, -2.f*Plane.Z*Plane.Z + 1.f, 0.f ),
39 TPlane<T>( 2.f*Plane.X*Plane.W, 2.f*Plane.Y*Plane.W, 2.f*Plane.Z*Plane.W, 1.f ) )
40{
41 //check( FMath::Abs(1.f - Plane.SizeSquared()) < KINDA_SMALL_NUMBER && TEXT("not normalized"));
42}
43
44} // namespace Math
45} // namespace UE
46
47UE_DECLARE_LWC_TYPE(MirrorMatrix, 44);
48
49template<> struct TIsUECoreVariant<FMirrorMatrix44f> { enum { Value = true }; };
50template<> struct TIsUECoreVariant<FMirrorMatrix44d> { enum { Value = true }; };
#define UE_DECLARE_LWC_TYPE(...)
#define FORCEINLINE
Definition Platform.h:644
#define TEMPLATE_REQUIRES(...)