OpenBarnyard
 
Loading...
Searching...
No Matches
TQuaternion.h
Go to the documentation of this file.
1
11
12#pragma once
13#include "Math/TVector3.h"
14#include "Math/TVector4.h"
15
17
19{
20public:
22 : x( 0.0f ), y( 0.0f ), z( 0.0f ), w( 1.0f )
23 {}
24
25 TQuaternion( const TQuaternion& a_pQuaternion )
26 : x( a_pQuaternion.x ), y( a_pQuaternion.y ), z( a_pQuaternion.z ), w( a_pQuaternion.w ) {}
27
28 TQuaternion( TFLOAT a_fX, TFLOAT a_fY, TFLOAT a_fZ, TFLOAT a_fW )
29 : x( a_fX ), y( a_fY ), z( a_fZ ), w( a_fW ) {}
30
31 void Set( TFLOAT a_fX, TFLOAT a_fY, TFLOAT a_fZ, TFLOAT a_fW )
32 {
33 x = a_fX;
34 y = a_fY;
35 z = a_fZ;
36 w = a_fW;
37 }
38
48
49 void SetFromEulerYX( const TFLOAT* fVal );
50 void SetFromEulerRollPitchYaw( TFLOAT a_fRoll, TFLOAT a_fPitch, TFLOAT a_fYaw );
51
52 inline void SetConjugate() { AsVector4().Negate3(); }
53 inline void SetInverse() { SetConjugate(); }
54 void SetRotation( const TVector3& a_rVec3, TFLOAT a_fVal );
55 void SetVectorDirection( const TVector3& a_rVec3, const TVector3& a_rVec3_2 );
56
57 static void RotateVector( TVector3& param_1, const TQuaternion& param_2, const TVector3 param_3 );
58 void RotateAroundAxis( const TVector3& param_1, TFLOAT param_2 );
59
60 void Negate() { Set( -x, -y, -z, -w ); }
61 void GetEulerXYZ( TVector3& outVec ) const;
62
63 TFLOAT Magnitude() const { return TMath::Sqrt( w * w + z * z + y * y + x * x ); }
64 TFLOAT MagnitudeSq() const { return w * w + z * z + y * y + x * x; }
65
66 const TVector4& AsVector4() const { return reinterpret_cast<const TVector4&>( *this ); }
67 TVector4& AsVector4() { return reinterpret_cast<TVector4&>( *this ); }
68
69 void operator=( const TQuaternion& other ) { Set( other.x, other.y, other.z, other.w ); }
70 TQuaternion& operator*=( const TQuaternion& a_rQuat );
71
72 static void Nlerp( TQuaternion& a_rOut, const TQuaternion& a_rStart, const TQuaternion& a_rEnd, float a_fProgress );
73 static void Slerp( TQuaternion& a_rOut, const TQuaternion& a_rStart, const TQuaternion& a_rEnd, float a_fProgress );
74
75public:
76 static const TQuaternion IDENTITY;
77 static inline constexpr TFLOAT DELTA = 0.001f;
78
79public:
80 TFLOAT x, y, z, w;
81};
82
3D vector implementation for the Toshi engine
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
float TFLOAT
Definition Typedefs.h:4
TFORCEINLINE TFLOAT Sqrt(TFLOAT a_fX)
Definition TMathInline.h:84
void GetEulerXYZ(TVector3 &outVec) const
void Set(TFLOAT a_fX, TFLOAT a_fY, TFLOAT a_fZ, TFLOAT a_fW)
Definition TQuaternion.h:31
TFLOAT MagnitudeSq() const
Definition TQuaternion.h:64
TFLOAT Magnitude() const
Definition TQuaternion.h:63
void operator=(const TQuaternion &other)
Definition TQuaternion.h:69
static constexpr TFLOAT DELTA
Definition TQuaternion.h:77
static const TQuaternion IDENTITY
Definition TQuaternion.h:7
void SetVectorDirection(const TVector3 &a_rVec3, const TVector3 &a_rVec3_2)
void SetRotation(const TVector3 &a_rVec3, TFLOAT a_fVal)
void SetInverse()
Definition TQuaternion.h:53
TQuaternion(const TQuaternion &a_pQuaternion)
Definition TQuaternion.h:25
static void RotateVector(TVector3 &param_1, const TQuaternion &param_2, const TVector3 param_3)
TVector4 & AsVector4()
Definition TQuaternion.h:67
void RotateAroundAxis(const TVector3 &param_1, TFLOAT param_2)
static void Nlerp(TQuaternion &a_rOut, const TQuaternion &a_rStart, const TQuaternion &a_rEnd, float a_fProgress)
void SetFromEulerYX(const TFLOAT *fVal)
void SetIdentity()
Definition TQuaternion.h:39
static void Slerp(TQuaternion &a_rOut, const TQuaternion &a_rStart, const TQuaternion &a_rEnd, float a_fProgress)
void SetConjugate()
Definition TQuaternion.h:52
void SetFromEulerRollPitchYaw(TFLOAT a_fRoll, TFLOAT a_fPitch, TFLOAT a_fYaw)
TQuaternion & operator*=(const TQuaternion &a_rQuat)
TQuaternion(TFLOAT a_fX, TFLOAT a_fY, TFLOAT a_fZ, TFLOAT a_fW)
Definition TQuaternion.h:28
const TVector4 & AsVector4() const
Definition TQuaternion.h:66
void Negate()
Definition TQuaternion.h:60
constexpr void Negate3(const TVector4 &vec)
Definition TVector4.h:265