OpenBarnyard
 
Loading...
Searching...
No Matches
TMath Namespace Reference

Functions

TBOOL ConeVsSphere (const TVector4 &a_rvConePosition, const TVector4 &a_rvConeDirection, float a_fConeFOV, float a_fSphereRadius, const TVector4 &a_rvSpherePosition)
 
TFORCEINLINE TBOOL IsFinite (TFLOAT fVal)
 
TFORCEINLINE TFLOAT Sin (TFLOAT fVal)
 
TFORCEINLINE TFLOAT Cos (TFLOAT fVal)
 
TFORCEINLINE TFLOAT Tan (TFLOAT fVal)
 
TFORCEINLINE TFLOAT ASin (TFLOAT fVal)
 
TFORCEINLINE TFLOAT ACos (TFLOAT fVal)
 
TFORCEINLINE TFLOAT ATan (TFLOAT fVal)
 
TFORCEINLINE TFLOAT ATan2 (TFLOAT fVal1, TFLOAT fVal2)
 
TFORCEINLINE TFLOAT Abs (TFLOAT fVal)
 
TFORCEINLINE constexpr TFLOAT DegToRad (TFLOAT fDeg)
 
TFORCEINLINE constexpr TUINT IntLog2 (TUINT32 a_uiValue)
 
constexpr TUINT RoundToNextPowerOfTwo (TUINT a_uiValue)
 
TFORCEINLINE TFLOAT Sqrt (TFLOAT a_fX)
 
TFORCEINLINE TFLOAT OneOverSqrt (TFLOAT a_fX)
 
TFORCEINLINE TINT Round (TFLOAT a_fVal)
 
TFORCEINLINE TINT CeilToInt (TFLOAT a_fVal)
 
TFORCEINLINE TINT FloorToInt (TFLOAT a_fVal)
 
TFORCEINLINE TBOOL IsNaN (TFLOAT fVal)
 
TFORCEINLINE TINT FastMod (TINT a_iNum, TINT a_iModulus)
 
TFORCEINLINE TFLOAT Pow (TFLOAT a_fValue, TFLOAT a_fPow)
 
TFORCEINLINE void SinCos (TFLOAT fVal, TFLOAT &a_rSin, TFLOAT &a_rCos)
 
TFORCEINLINE TFLOAT LERP (TFLOAT a, TFLOAT b, TFLOAT t)
 
TFORCEINLINE TFLOAT LERPClamped (TFLOAT a, TFLOAT b, TFLOAT t)
 
TFORCEINLINE void NormaliseAngle (TFLOAT &a_rfValue)
 
template<typename T>
TFORCEINLINE void Clip (T &rVal, const T &Min, const T &Max)
 
template<typename T>
TFORCEINLINE const T & Min (const T &a, const T &b)
 
template<typename T>
TFORCEINLINE const T & Max (const T &a, const T &b)
 

Variables

constexpr TINT8 TINT8_MAX = INT8_MAX
 
constexpr TINT8 TINT8_MIN = INT8_MIN
 
constexpr TUINT8 TUINT8_MAX = UINT8_MAX
 
constexpr TUINT TINT16_MAX = INT16_MAX
 
constexpr TUINT TINT16_MIN = INT16_MIN
 
constexpr TUINT TUINT16_MAX = UINT16_MAX
 
constexpr TINT TINT32_MAX = INT32_MAX
 
constexpr TINT TINT32_MIN = INT32_MIN
 
constexpr TUINT TUINT32_MAX = UINT32_MAX
 
constexpr TUINT16 MAXWCHAR = WCHAR_MAX
 
constexpr TUINTPTR MAXPTR = UINTPTR_MAX
 
constexpr TFLOAT MAXFLOAT = FLT_MAX
 
constexpr TFLOAT MINFLOAT = FLT_MIN
 
constexpr TFLOAT TFLOAT_EPSILON = FLT_EPSILON
 
constexpr TFLOAT FLOATEPSILON = FLT_EPSILON
 
constexpr TFLOAT PI = 3.1415927f
 
constexpr TFLOAT TWO_PI = PI * 2
 
constexpr TFLOAT HALF_PI = PI / 2
 
constexpr TFLOAT ONEOVER_SQRT_TWO = 0.70710677f
 
constexpr TFLOAT ONEOVERTWO_PI = 1 / TWO_PI
 

Function Documentation

◆ Abs()

TFORCEINLINE TFLOAT TMath::Abs ( TFLOAT fVal)

Definition at line 63 of file TMathInline.h.

63{ return (TFLOAT)fabs( fVal ); }
float TFLOAT
Definition Typedefs.h:4

◆ ACos()

TFORCEINLINE TFLOAT TMath::ACos ( TFLOAT fVal)

Definition at line 50 of file TMathInline.h.

50{ return acosf( fVal ); }

◆ ASin()

TFORCEINLINE TFLOAT TMath::ASin ( TFLOAT fVal)

Definition at line 47 of file TMathInline.h.

47{ return asinf( fVal ); }

◆ ATan()

TFORCEINLINE TFLOAT TMath::ATan ( TFLOAT fVal)

Definition at line 51 of file TMathInline.h.

52{
53 TFLOAT fRes = atanf( fVal );
54 TASSERT( TMath::IsFinite( fRes ) );
55 return fRes;
56}
#define TASSERT(X,...)
Definition Defines.h:138
TFORCEINLINE TBOOL IsFinite(TFLOAT fVal)
Definition TMathInline.h:41

◆ ATan2()

TFORCEINLINE TFLOAT TMath::ATan2 ( TFLOAT fVal1,
TFLOAT fVal2 )

Definition at line 57 of file TMathInline.h.

58{
59 TFLOAT fRes = atan2f( fVal1, fVal2 );
60 TASSERT( TMath::IsFinite( fRes ) );
61 return fRes;
62}

◆ CeilToInt()

TFORCEINLINE TINT TMath::CeilToInt ( TFLOAT a_fVal)

Definition at line 100 of file TMathInline.h.

100{ return TINT( a_fVal ) - TUINT32( 0 < TUINT32( a_fVal - TUINT32( a_fVal ) ) ); }
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7

◆ Clip()

template<typename T>
TFORCEINLINE void TMath::Clip ( T & rVal,
const T & Min,
const T & Max )

Definition at line 154 of file TMathInline.h.

155{
156 if ( Max < rVal ) { rVal = Max; }
157 if ( rVal < Min ) { rVal = Min; }
158}
TFORCEINLINE const T & Max(const T &a, const T &b)
TFORCEINLINE const T & Min(const T &a, const T &b)

◆ ConeVsSphere()

TBOOL TMath::ConeVsSphere ( const TVector4 & a_rvConePosition,
const TVector4 & a_rvConeDirection,
float a_fConeFOV,
float a_fSphereRadius,
const TVector4 & a_rvSpherePosition )

◆ Cos()

TFORCEINLINE TFLOAT TMath::Cos ( TFLOAT fVal)

Definition at line 43 of file TMathInline.h.

43{ return cosf( fVal ); }

◆ DegToRad()

TFORCEINLINE constexpr TFLOAT TMath::DegToRad ( TFLOAT fDeg)
constexpr

Definition at line 64 of file TMathInline.h.

64{ return ( fDeg / 180.0f ) * PI; }
constexpr TFLOAT PI
Definition TMathInline.h:35

◆ FastMod()

TFORCEINLINE TINT TMath::FastMod ( TINT a_iNum,
TINT a_iModulus )

Definition at line 107 of file TMathInline.h.

108{
109 TASSERT( a_iNum >= 0 );
110 TASSERT( a_iModulus > 0 );
111 TASSERT( 0 == ( a_iModulus & ( a_iModulus - 1 ) ) );
112 return a_iNum & ( a_iModulus - 1 );
113}

◆ FloorToInt()

TFORCEINLINE TINT TMath::FloorToInt ( TFLOAT a_fVal)

Definition at line 103 of file TMathInline.h.

103{ return TINT( a_fVal ) - TUINT32( 0x80000000 < TUINT32( a_fVal - TUINT32( a_fVal ) ) ); }

◆ IntLog2()

TFORCEINLINE constexpr TUINT TMath::IntLog2 ( TUINT32 a_uiValue)
constexpr

Definition at line 66 of file TMathInline.h.

67{
68 return std::bit_width( a_uiValue ) - 1;
69}

◆ IsFinite()

TFORCEINLINE TBOOL TMath::IsFinite ( TFLOAT fVal)

Definition at line 41 of file TMathInline.h.

41{ return _finite( fVal ) != 0; }

◆ IsNaN()

TFORCEINLINE TBOOL TMath::IsNaN ( TFLOAT fVal)

Definition at line 105 of file TMathInline.h.

105{ return isnan( fVal ); }

◆ LERP()

TFORCEINLINE TFLOAT TMath::LERP ( TFLOAT a,
TFLOAT b,
TFLOAT t )

Definition at line 129 of file TMathInline.h.

129{ return a + t * ( b - a ); }

◆ LERPClamped()

TFORCEINLINE TFLOAT TMath::LERPClamped ( TFLOAT a,
TFLOAT b,
TFLOAT t )

Definition at line 132 of file TMathInline.h.

133{
134 TFLOAT fResult = LERP( a, b, t );
135
136 if ( ( a < b && b < fResult ) || ( b < a && fResult < b ) )
137 return b;
138
139 return fResult;
140}
TFORCEINLINE TFLOAT LERP(TFLOAT a, TFLOAT b, TFLOAT t)

◆ Max()

template<typename T>
TFORCEINLINE const T & TMath::Max ( const T & a,
const T & b )

Definition at line 167 of file TMathInline.h.

168{
169 return ( a < b ) ? b : a;
170}

◆ Min()

template<typename T>
TFORCEINLINE const T & TMath::Min ( const T & a,
const T & b )

Definition at line 161 of file TMathInline.h.

162{
163 return ( a < b ) ? a : b;
164}

◆ NormaliseAngle()

TFORCEINLINE void TMath::NormaliseAngle ( TFLOAT & a_rfValue)

Definition at line 143 of file TMathInline.h.

144{
145 if ( PI < a_rfValue )
146 a_rfValue = fmodf( a_rfValue + PI, PI * 2 ) - PI;
147 else if ( a_rfValue < -PI )
148 a_rfValue = fmodf( a_rfValue - PI, PI * 2 ) + PI;
149}

◆ OneOverSqrt()

TFORCEINLINE TFLOAT TMath::OneOverSqrt ( TFLOAT a_fX)

Definition at line 92 of file TMathInline.h.

93{
94 return 1.0f / Sqrt( a_fX );
95}
TFORCEINLINE TFLOAT Sqrt(TFLOAT a_fX)
Definition TMathInline.h:84

◆ Pow()

TFORCEINLINE TFLOAT TMath::Pow ( TFLOAT a_fValue,
TFLOAT a_fPow )

Definition at line 116 of file TMathInline.h.

117{
118 return powf( a_fValue, a_fPow );
119}

◆ Round()

TFORCEINLINE TINT TMath::Round ( TFLOAT a_fVal)

Definition at line 97 of file TMathInline.h.

97{ return (TINT)roundf( a_fVal ); }

◆ RoundToNextPowerOfTwo()

TUINT TMath::RoundToNextPowerOfTwo ( TUINT a_uiValue)
inlineconstexpr

Definition at line 71 of file TMathInline.h.

72{
73 a_uiValue--;
74 a_uiValue |= a_uiValue >> 1;
75 a_uiValue |= a_uiValue >> 2;
76 a_uiValue |= a_uiValue >> 4;
77 a_uiValue |= a_uiValue >> 8;
78 a_uiValue |= a_uiValue >> 16;
79 a_uiValue++;
80
81 return a_uiValue;
82}

◆ Sin()

TFORCEINLINE TFLOAT TMath::Sin ( TFLOAT fVal)

Definition at line 42 of file TMathInline.h.

42{ return sinf( fVal ); }

◆ SinCos()

TFORCEINLINE void TMath::SinCos ( TFLOAT fVal,
TFLOAT & a_rSin,
TFLOAT & a_rCos )

Definition at line 122 of file TMathInline.h.

123{
124 a_rSin = sinf( fVal );
125 a_rCos = cosf( fVal );
126}

◆ Sqrt()

TFORCEINLINE TFLOAT TMath::Sqrt ( TFLOAT a_fX)

Definition at line 84 of file TMathInline.h.

85{
86 TASSERT( a_fX != 0.0f );
87 TFLOAT fVal = sqrtf( a_fX );
88 TASSERT( IsFinite( fVal ) );
89 return fVal;
90}

◆ Tan()

TFORCEINLINE TFLOAT TMath::Tan ( TFLOAT fVal)

Definition at line 44 of file TMathInline.h.

44{ return tanf( fVal ); }

Variable Documentation

◆ FLOATEPSILON

TFLOAT TMath::FLOATEPSILON = FLT_EPSILON
constexpr

Definition at line 33 of file TMathInline.h.

◆ HALF_PI

TFLOAT TMath::HALF_PI = PI / 2
constexpr

Definition at line 37 of file TMathInline.h.

◆ MAXFLOAT

TFLOAT TMath::MAXFLOAT = FLT_MAX
constexpr

Definition at line 30 of file TMathInline.h.

◆ MAXPTR

TUINTPTR TMath::MAXPTR = UINTPTR_MAX
constexpr

Definition at line 28 of file TMathInline.h.

◆ MAXWCHAR

TUINT16 TMath::MAXWCHAR = WCHAR_MAX
constexpr

Definition at line 26 of file TMathInline.h.

◆ MINFLOAT

TFLOAT TMath::MINFLOAT = FLT_MIN
constexpr

Definition at line 31 of file TMathInline.h.

◆ ONEOVER_SQRT_TWO

TFLOAT TMath::ONEOVER_SQRT_TWO = 0.70710677f
constexpr

Definition at line 38 of file TMathInline.h.

◆ ONEOVERTWO_PI

TFLOAT TMath::ONEOVERTWO_PI = 1 / TWO_PI
constexpr

Definition at line 39 of file TMathInline.h.

◆ PI

TFLOAT TMath::PI = 3.1415927f
constexpr

Definition at line 35 of file TMathInline.h.

◆ TFLOAT_EPSILON

TFLOAT TMath::TFLOAT_EPSILON = FLT_EPSILON
constexpr

Definition at line 32 of file TMathInline.h.

◆ TINT16_MAX

TUINT TMath::TINT16_MAX = INT16_MAX
constexpr

Definition at line 18 of file TMathInline.h.

◆ TINT16_MIN

TUINT TMath::TINT16_MIN = INT16_MIN
constexpr

Definition at line 19 of file TMathInline.h.

◆ TINT32_MAX

TINT TMath::TINT32_MAX = INT32_MAX
constexpr

Definition at line 22 of file TMathInline.h.

◆ TINT32_MIN

TINT TMath::TINT32_MIN = INT32_MIN
constexpr

Definition at line 23 of file TMathInline.h.

◆ TINT8_MAX

TINT8 TMath::TINT8_MAX = INT8_MAX
constexpr

Definition at line 14 of file TMathInline.h.

◆ TINT8_MIN

TINT8 TMath::TINT8_MIN = INT8_MIN
constexpr

Definition at line 15 of file TMathInline.h.

◆ TUINT16_MAX

TUINT TMath::TUINT16_MAX = UINT16_MAX
constexpr

Definition at line 20 of file TMathInline.h.

◆ TUINT32_MAX

TUINT TMath::TUINT32_MAX = UINT32_MAX
constexpr

Definition at line 24 of file TMathInline.h.

◆ TUINT8_MAX

TUINT8 TMath::TUINT8_MAX = UINT8_MAX
constexpr

Definition at line 16 of file TMathInline.h.

◆ TWO_PI

TFLOAT TMath::TWO_PI = PI * 2
constexpr

Definition at line 36 of file TMathInline.h.