Slippers Engine
 
Loading...
Searching...
No Matches
Math Tools

Collection of math tools. More...

Topics

 Movement
 

Functions

static float MathTools::FastSqrt (float x)
 Calculate Sqrt without std::sqrt.
 
static float MathTools::RandFloat (float lower, float upper)
 Generates Random Floating Point Number using std::random_device.
 
static float MathTools::DegToRad (float a)
 Converts angle in degrees to angle in radians.
 
static float MathTools::RadToDeg (float a)
 Converts angle in radians to angle in degrees.
 
static std::vector< Vect > MathTools::ScreenToWorldPersp (float x, float y)
 Takes a screen position and returns the world position at the near and far clip plane.
 

Detailed Description

Collection of math tools.

Function Documentation

◆ DegToRad()

float MathTools::DegToRad ( float a)
static

Converts angle in degrees to angle in radians.

Parameters
a
Returns
float

◆ FastSqrt()

float MathTools::FastSqrt ( float x)
static

Calculate Sqrt without std::sqrt.

//Runs in 2-5 cycles compared to std::sqrt's 10+ but has an errors percantage between 1%-4.5%
//Can be as far off as 1 whole unit
float MathTools::FastSqrt(float x) {
union { float f; uint32_t i; } u = { x };
u.i = 0x1FBD1DF5 + (u.i >> 1); // Magic number approximation
return u.f;
}
static float FastSqrt(float x)
Calculate Sqrt without std::sqrt.
Definition MathTools.cpp:20
Parameters
x
Returns
float

◆ RadToDeg()

float MathTools::RadToDeg ( float a)
static

Converts angle in radians to angle in degrees.

Parameters
a
Returns
float

◆ RandFloat()

float MathTools::RandFloat ( float lower,
float upper )
static

Generates Random Floating Point Number using std::random_device.

Parameters
lower
upper
Returns
float

◆ ScreenToWorldPersp()

std::vector< Vect > MathTools::ScreenToWorldPersp ( float x,
float y )
static

Takes a screen position and returns the world position at the near and far clip plane.

Parameters
x
y
Returns
std::vector<Vect>