OpenBarnyard
 
Loading...
Searching...
No Matches
TVector3 Class Reference

#include <TVector3.h>

Public Member Functions

constexpr TVector3 ()=default
 
constexpr TVector3 (TFLOAT x, TFLOAT y, TFLOAT z)
 
constexpr TVector3 (TFLOAT floats[3])
 
constexpr TVector3 (const TVector3 &other)
 
void Clip (TFLOAT fVal, TFLOAT fVal2)
 
void CrossProduct (const TVector3 &, const TVector3 &)
 
void RotateX (TFLOAT a_fRotation)
 
void RotateY (TFLOAT a_fRotation)
 
void RotateZ (TFLOAT a_fRotation)
 
void Normalize ()
 
constexpr void Set (const TVector3 &vec)
 
constexpr void Set (TFLOAT floats[3])
 
constexpr void Set (TFLOAT x, TFLOAT y, TFLOAT z)
 
constexpr void Lerp (const TVector3 &finish, float t)
 
constexpr void Lerp (const TVector3 &start, const TVector3 &finish, float t)
 
constexpr void Add (const TVector3 &vec)
 
constexpr void Add (const TVector3 &a, const TVector3 &b)
 
constexpr void Divide (const TVector3 &vec)
 
constexpr void Divide (TFLOAT scalar)
 
constexpr void Divide (const TVector3 &vec1, const TVector3 &vec2)
 
constexpr void Divide (const TVector3 &vec, TFLOAT scalar)
 
constexpr void Multiply (const TVector3 &vec)
 
constexpr void Multiply (TFLOAT scalar)
 
constexpr void Multiply (const TVector3 &vec1, const TVector3 &vec2)
 
constexpr void Multiply (const TVector3 &vec, TFLOAT scalar)
 
void Abs (const TVector3 &vec3)
 
void Abs ()
 
TFLOAT Magnitude () const
 
constexpr TFLOAT MagnitudeSq () const
 
constexpr TVector3 operator+ (const TVector3 &other) const
 
constexpr TVector3 operator- (const TVector3 &other) const
 
constexpr TVector3 operator* (const TVector3 &other) const
 
constexpr TVector3 operator/ (const TVector3 &other) const
 
constexpr void operator= (const TVector3 &other)
 
constexpr void operator+= (const TVector3 &other)
 
constexpr void operator/= (const TVector3 &other)
 

Static Public Member Functions

static TFLOAT Distance (const TVector3 &vec1, const TVector3 &vec2)
 
static constexpr TFLOAT DistanceSq (const TVector3 &vec1, const TVector3 &vec2)
 
static constexpr TFLOAT DotProduct (const TVector3 &vec1, const TVector3 &vec2)
 

Public Attributes

TFLOAT x
 
TFLOAT y
 
TFLOAT z
 

Static Public Attributes

static constinit const TVector3 VEC_ZERO = TVector3( 0, 0, 0 )
 
static constinit const TVector3 VEC_POSX = TVector3( 1, 0, 0 )
 
static constinit const TVector3 VEC_POSY = TVector3( 0, 1, 0 )
 
static constinit const TVector3 VEC_POSZ = TVector3( 0, 0, 1 )
 
static constinit const TVector3 VEC_NEGX = TVector3( -1, 0, 0 )
 
static constinit const TVector3 VEC_NEGY = TVector3( 0, -1, 0 )
 
static constinit const TVector3 VEC_NEGZ = TVector3( 0, 0, -1 )
 
static constinit const TVector3 VEC_NEGXPOSZ = TVector3( -TMath::ONEOVER_SQRT_TWO, 0, TMath::ONEOVER_SQRT_TWO )
 
static constinit const TVector3 VEC_NEGXNEGZ = TVector3( -TMath::ONEOVER_SQRT_TWO, 0, -TMath::ONEOVER_SQRT_TWO )
 
static constinit const TVector3 VEC_POSXPOSZ = TVector3( TMath::ONEOVER_SQRT_TWO, 0, TMath::ONEOVER_SQRT_TWO )
 
static constinit const TVector3 VEC_POSXNEGZ = TVector3( TMath::ONEOVER_SQRT_TWO, 0, -TMath::ONEOVER_SQRT_TWO )
 

Detailed Description

Definition at line 16 of file TVector3.h.

Constructor & Destructor Documentation

◆ TVector3() [1/4]

TVector3::TVector3 ( )
constexprdefault

◆ TVector3() [2/4]

TVector3::TVector3 ( TFLOAT x,
TFLOAT y,
TFLOAT z )
inlineconstexpr

Definition at line 20 of file TVector3.h.

20{ Set( x, y, z ); }
TFLOAT y
Definition TVector3.h:163
constexpr void Set(const TVector3 &vec)
Definition TVector3.h:33
TFLOAT z
Definition TVector3.h:163
TFLOAT x
Definition TVector3.h:163

◆ TVector3() [3/4]

TVector3::TVector3 ( TFLOAT floats[3])
inlineconstexpr

Definition at line 21 of file TVector3.h.

21{ Set( floats ); }

◆ TVector3() [4/4]

TVector3::TVector3 ( const TVector3 & other)
inlineconstexpr

Definition at line 22 of file TVector3.h.

22{ Set( other.x, other.y, other.z ); }

Member Function Documentation

◆ Abs() [1/2]

void TVector3::Abs ( )
inline

Definition at line 129 of file TVector3.h.

129{ Set( TMath::Abs( x ), TMath::Abs( y ), TMath::Abs( z ) ); }
TFORCEINLINE TFLOAT Abs(TFLOAT fVal)
Definition TMathInline.h:63

◆ Abs() [2/2]

void TVector3::Abs ( const TVector3 & vec3)
inline

Definition at line 128 of file TVector3.h.

128{ Set( TMath::Abs( vec3.x ), TMath::Abs( vec3.y ), TMath::Abs( vec3.z ) ); }

◆ Add() [1/2]

void TVector3::Add ( const TVector3 & a,
const TVector3 & b )
inlineconstexpr

Definition at line 72 of file TVector3.h.

73 {
74 Set( a + b );
75 }

◆ Add() [2/2]

void TVector3::Add ( const TVector3 & vec)
inlineconstexpr

Definition at line 65 of file TVector3.h.

66 {
67 x += vec.x;
68 y += vec.y;
69 z += vec.z;
70 }

◆ Clip()

void TVector3::Clip ( TFLOAT fVal,
TFLOAT fVal2 )

Definition at line 18 of file TVector3.cpp.

19{
20 TMath::Clip( x, fVal, fVal2 );
21 TMath::Clip( y, fVal, fVal2 );
22 TMath::Clip( z, fVal, fVal2 );
23}
TFORCEINLINE void Clip(T &rVal, const T &Min, const T &Max)

◆ CrossProduct()

void TVector3::CrossProduct ( const TVector3 & vec1,
const TVector3 & vec2 )

Definition at line 25 of file TVector3.cpp.

26{
27 TFLOAT fX = vec2.z * vec1.y - vec2.y * vec1.z;
28 TFLOAT fY = vec1.z * vec2.x - vec2.z * vec1.x;
29 TFLOAT fZ = vec1.x * vec2.y - vec1.y * vec2.x;
30 Set( fX, fY, fZ );
31}
float TFLOAT
Definition Typedefs.h:4

◆ Distance()

static TFLOAT TVector3::Distance ( const TVector3 & vec1,
const TVector3 & vec2 )
inlinestatic

Definition at line 145 of file TVector3.h.

145{ return ( vec2 - vec1 ).Magnitude(); }

◆ DistanceSq()

static constexpr TFLOAT TVector3::DistanceSq ( const TVector3 & vec1,
const TVector3 & vec2 )
inlinestaticconstexpr

Definition at line 146 of file TVector3.h.

146{ return ( vec2 - vec1 ).MagnitudeSq(); }

◆ Divide() [1/4]

void TVector3::Divide ( const TVector3 & vec)
inlineconstexpr

Definition at line 77 of file TVector3.h.

78 {
79 x /= vec.x;
80 y /= vec.y;
81 z /= vec.z;
82 }

◆ Divide() [2/4]

void TVector3::Divide ( const TVector3 & vec,
TFLOAT scalar )
inlineconstexpr

Definition at line 97 of file TVector3.h.

98 {
99 Set( vec );
100 Divide( scalar );
101 }
constexpr void Divide(const TVector3 &vec)
Definition TVector3.h:77

◆ Divide() [3/4]

void TVector3::Divide ( const TVector3 & vec1,
const TVector3 & vec2 )
inlineconstexpr

Definition at line 92 of file TVector3.h.

93 {
94 Set( vec1 / vec2 );
95 }

◆ Divide() [4/4]

void TVector3::Divide ( TFLOAT scalar)
inlineconstexpr

Definition at line 84 of file TVector3.h.

85 {
86 TFLOAT ratio = 1.0f / scalar;
87 x *= ratio;
88 y *= ratio;
89 z *= ratio;
90 }

◆ DotProduct()

static constexpr TFLOAT TVector3::DotProduct ( const TVector3 & vec1,
const TVector3 & vec2 )
inlinestaticconstexpr

Definition at line 147 of file TVector3.h.

147{ return vec1.x * vec2.x + vec1.y * vec2.y + vec1.z * vec2.z; }

◆ Lerp() [1/2]

void TVector3::Lerp ( const TVector3 & finish,
float t )
inlineconstexpr

Definition at line 53 of file TVector3.h.

53{ Lerp( *this, finish, t ); }
constexpr void Lerp(const TVector3 &finish, float t)
Definition TVector3.h:53

◆ Lerp() [2/2]

void TVector3::Lerp ( const TVector3 & start,
const TVector3 & finish,
float t )
inlineconstexpr

Definition at line 56 of file TVector3.h.

57 {
58 TVector3 progress = finish - start;
59 progress.Multiply( t );
60
61 Set( start + progress );
62 }
constexpr void Multiply(const TVector3 &vec)
Definition TVector3.h:103
constexpr TVector3()=default

◆ Magnitude()

TFLOAT TVector3::Magnitude ( ) const
inline

Definition at line 132 of file TVector3.h.

132{ return TMath::Sqrt( x * x + y * y + z * z ); }
TFORCEINLINE TFLOAT Sqrt(TFLOAT a_fX)
Definition TMathInline.h:84

◆ MagnitudeSq()

TFLOAT TVector3::MagnitudeSq ( ) const
inlineconstexpr

Definition at line 133 of file TVector3.h.

133{ return x * x + y * y + z * z; }

◆ Multiply() [1/4]

void TVector3::Multiply ( const TVector3 & vec)
inlineconstexpr

Definition at line 103 of file TVector3.h.

104 {
105 x *= vec.x;
106 y *= vec.y;
107 z *= vec.z;
108 }

◆ Multiply() [2/4]

void TVector3::Multiply ( const TVector3 & vec,
TFLOAT scalar )
inlineconstexpr

Definition at line 122 of file TVector3.h.

123 {
124 Set( vec );
125 Multiply( scalar );
126 }

◆ Multiply() [3/4]

void TVector3::Multiply ( const TVector3 & vec1,
const TVector3 & vec2 )
inlineconstexpr

Definition at line 117 of file TVector3.h.

118 {
119 Set( vec1 * vec2 );
120 }

◆ Multiply() [4/4]

void TVector3::Multiply ( TFLOAT scalar)
inlineconstexpr

Definition at line 110 of file TVector3.h.

111 {
112 x *= scalar;
113 y *= scalar;
114 z *= scalar;
115 }

◆ Normalize()

void TVector3::Normalize ( )

Definition at line 71 of file TVector3.cpp.

72{
73 if ( MagnitudeSq() != 0.0f )
74 {
75 TFLOAT magnitude = TMath::OneOverSqrt( MagnitudeSq() );
76 Set( x * magnitude, y * magnitude, z * magnitude );
77 }
78 else
79 {
80 Set( 0.0f, 0.0f, 1.0f );
81 }
82}
TFORCEINLINE TFLOAT OneOverSqrt(TFLOAT a_fX)
Definition TMathInline.h:92
constexpr TFLOAT MagnitudeSq() const
Definition TVector3.h:133

◆ operator*()

TVector3 TVector3::operator* ( const TVector3 & other) const
inlineconstexpr

Definition at line 137 of file TVector3.h.

137{ return { x * other.x, y * other.y, z * other.z }; }

◆ operator+()

TVector3 TVector3::operator+ ( const TVector3 & other) const
inlineconstexpr

Definition at line 135 of file TVector3.h.

135{ return { x + other.x, y + other.y, z + other.z }; }

◆ operator+=()

void TVector3::operator+= ( const TVector3 & other)
inlineconstexpr

Definition at line 141 of file TVector3.h.

141{ Add( other ); }
constexpr void Add(const TVector3 &vec)
Definition TVector3.h:65

◆ operator-()

TVector3 TVector3::operator- ( const TVector3 & other) const
inlineconstexpr

Definition at line 136 of file TVector3.h.

136{ return { x - other.x, y - other.y, z - other.z }; }

◆ operator/()

TVector3 TVector3::operator/ ( const TVector3 & other) const
inlineconstexpr

Definition at line 138 of file TVector3.h.

138{ return { x / other.x, y / other.y, z / other.z }; }

◆ operator/=()

void TVector3::operator/= ( const TVector3 & other)
inlineconstexpr

Definition at line 142 of file TVector3.h.

142{ Divide( other ); }

◆ operator=()

void TVector3::operator= ( const TVector3 & other)
inlineconstexpr

Definition at line 140 of file TVector3.h.

140{ Set( other ); }

◆ RotateX()

void TVector3::RotateX ( TFLOAT a_fRotation)

Definition at line 34 of file TVector3.cpp.

35{
36 TFLOAT f1;
37 TFLOAT f2;
38 TFLOAT oldY = y;
39
40 TMath::SinCos( a_fRotation, f1, f2 );
41
42 y = -f1 * z + f2 * oldY;
43 z = oldY * f1 + z * f2;
44}
TFORCEINLINE void SinCos(TFLOAT fVal, TFLOAT &a_rSin, TFLOAT &a_rCos)

◆ RotateY()

void TVector3::RotateY ( TFLOAT a_fRotation)

Definition at line 47 of file TVector3.cpp.

48{
49 TFLOAT f1;
50 TFLOAT f2;
51 TFLOAT oldX = x;
52
53 TMath::SinCos( a_fRotation, f1, f2 );
54
55 x = f1 * z + f2 * oldX;
56 z = z * f2 + -f1 * oldX;
57}

◆ RotateZ()

void TVector3::RotateZ ( TFLOAT a_fRotation)

Definition at line 59 of file TVector3.cpp.

60{
61 TFLOAT f1;
62 TFLOAT f2;
63 TFLOAT oldX = x;
64
65 TMath::SinCos( a_fRotation, f1, f2 );
66
67 x = -f1 * y + f2 * oldX;
68 y = f1 * oldX + y * f2;
69}

◆ Set() [1/3]

void TVector3::Set ( const TVector3 & vec)
inlineconstexpr

Definition at line 33 of file TVector3.h.

34 {
35 TVector3::x = vec.x;
36 TVector3::y = vec.y;
37 TVector3::z = vec.z;
38 }

◆ Set() [2/3]

void TVector3::Set ( TFLOAT floats[3])
inlineconstexpr

Definition at line 39 of file TVector3.h.

40 {
41 TVector3::x = floats[ 0 ];
42 TVector3::y = floats[ 1 ];
43 TVector3::z = floats[ 2 ];
44 }

◆ Set() [3/3]

void TVector3::Set ( TFLOAT x,
TFLOAT y,
TFLOAT z )
inlineconstexpr

Definition at line 45 of file TVector3.h.

46 {
47 TVector3::x = x;
48 TVector3::y = y;
49 TVector3::z = z;
50 }

Member Data Documentation

◆ VEC_NEGX

const TVector3 TVector3::VEC_NEGX = TVector3( -1, 0, 0 )
staticconstinit

Definition at line 154 of file TVector3.h.

◆ VEC_NEGXNEGZ

const TVector3 TVector3::VEC_NEGXNEGZ = TVector3( -TMath::ONEOVER_SQRT_TWO, 0, -TMath::ONEOVER_SQRT_TWO )
staticconstinit

Definition at line 158 of file TVector3.h.

◆ VEC_NEGXPOSZ

const TVector3 TVector3::VEC_NEGXPOSZ = TVector3( -TMath::ONEOVER_SQRT_TWO, 0, TMath::ONEOVER_SQRT_TWO )
staticconstinit

Definition at line 157 of file TVector3.h.

◆ VEC_NEGY

const TVector3 TVector3::VEC_NEGY = TVector3( 0, -1, 0 )
staticconstinit

Definition at line 155 of file TVector3.h.

◆ VEC_NEGZ

const TVector3 TVector3::VEC_NEGZ = TVector3( 0, 0, -1 )
staticconstinit

Definition at line 156 of file TVector3.h.

◆ VEC_POSX

const TVector3 TVector3::VEC_POSX = TVector3( 1, 0, 0 )
staticconstinit

Definition at line 151 of file TVector3.h.

◆ VEC_POSXNEGZ

const TVector3 TVector3::VEC_POSXNEGZ = TVector3( TMath::ONEOVER_SQRT_TWO, 0, -TMath::ONEOVER_SQRT_TWO )
staticconstinit

Definition at line 160 of file TVector3.h.

◆ VEC_POSXPOSZ

const TVector3 TVector3::VEC_POSXPOSZ = TVector3( TMath::ONEOVER_SQRT_TWO, 0, TMath::ONEOVER_SQRT_TWO )
staticconstinit

Definition at line 159 of file TVector3.h.

◆ VEC_POSY

const TVector3 TVector3::VEC_POSY = TVector3( 0, 1, 0 )
staticconstinit

Definition at line 152 of file TVector3.h.

◆ VEC_POSZ

const TVector3 TVector3::VEC_POSZ = TVector3( 0, 0, 1 )
staticconstinit

Definition at line 153 of file TVector3.h.

◆ VEC_ZERO

const TVector3 TVector3::VEC_ZERO = TVector3( 0, 0, 0 )
staticconstinit

Definition at line 150 of file TVector3.h.

◆ x

TFLOAT TVector3::x

Definition at line 163 of file TVector3.h.

◆ y

TFLOAT TVector3::y

Definition at line 163 of file TVector3.h.

◆ z

TFLOAT TVector3::z

Definition at line 163 of file TVector3.h.


The documentation for this class was generated from the following files: