philsupertramp/game-math
|
Functions | |
template<class V > | |
float | distance (const V &a, const V &b) |
template<class T > | |
vec2< T > | normalize (const vec2< T > &a) |
template<class T > | |
vec3< T > | normalize (const vec3< T > &a) |
template<class T > | |
vec4< T > | normalize (const vec4< T > &a) |
template<class T > | |
mat4< T > | translate (const mat4< T > &M, const vec3< T > &V) |
template<class T > | |
mat4< T > | lookAt (const vec3< T > &eye, const vec3< T > ¢er, const vec3< T > &up) |
template<class T > | |
mat4< T > | ortho (const float &left, const float &right, const float &bottom, const float &top) |
template<class T > | |
mat4< T > | perspective (const float &FOV, const float &width, const float &height, const float &zNear, const float &zFar) |
template<class T > | |
mat4< T > | angleAxis (const float &angle, const vec3< T > &axis) |
template<class T > | |
mat4< T > | scale (const mat4< T > &mat, const float &factor) |
template<class T > | |
mat4< T > | scale (const mat4< T > &mat, const vec3< T > &factor) |
template<typename T , typename U > | |
vec3< T > | unProject (vec3< T > const &win, mat4< T > const &model, mat4< T > const &proj, vec4< U > const &viewport) |
template<class T > | |
mat4< T > | rotate (const mat4< T > &m, const float &angle, vec3< T > u) |
template<class T > | |
vec3< T > | max (const vec3< T > &a, const vec3< T > &b) |
template<class T > | |
vec3< T > | lerp (const vec3< T > &p1, const vec3< T > &p2, const float &v) |
template<class T > | |
vec4< T > | lerp (const vec4< T > &p1, const vec4< T > &p2, const float &v) |
float Math::Utils::distance | ( | const V & | a, |
const V & | b | ||
) |
Calculates distance between given vectors
V |
a | |
b |
vec3< T > Math::Utils::lerp | ( | const vec3< T > & | p1, |
const vec3< T > & | p2, | ||
const float & | v | ||
) |
linear interpolates a 3D-vector by given values
T |
p1 | |
p2 | |
v |
vec4< T > Math::Utils::lerp | ( | const vec4< T > & | p1, |
const vec4< T > & | p2, | ||
const float & | v | ||
) |
linear interpolates a 4D-vector by given values
T |
p1 | |
p2 | |
v |
mat4< T > Math::Utils::lookAt | ( | const vec3< T > & | eye, |
const vec3< T > & | center, | ||
const vec3< T > & | up | ||
) |
Computes look at matrix for given data
T |
eye | |
center | |
up |
Computes max-value between two given 3D-vectors
T |
a | |
b |
helper to normalize 3D-vector
T |
a |
helper to normalize 4D-vector
T |
a |
mat4< T > Math::Utils::ortho | ( | const float & | left, |
const float & | right, | ||
const float & | bottom, | ||
const float & | top | ||
) |
calculates orthogonal projection plane
T |
left | |
right | |
bottom | |
top |
mat4< T > Math::Utils::perspective | ( | const float & | FOV, |
const float & | width, | ||
const float & | height, | ||
const float & | zNear, | ||
const float & | zFar | ||
) |
Computes perspective projection matrix
T |
FOV | |
width | |
height | |
zNear | |
zFar |
mat4< T > Math::Utils::rotate | ( | const mat4< T > & | m, |
const float & | angle, | ||
vec3< T > | u | ||
) |
Rotates a given matrix m by an angle angle around given axis u
T |
m | |
angle | |
u |
scales a given matrix by a factor
T |
mat | |
factor |
Translates a given 4-by-4 matrix M by given vector V
T |
M | |
V |
vec3< T > Math::Utils::unProject | ( | vec3< T > const & | win, |
mat4< T > const & | model, | ||
mat4< T > const & | proj, | ||
vec4< U > const & | viewport | ||
) |
Inverts projection
T | |
U |
win | 3D point to convert from window space |
model | (model * view)-matrix |
proj | projection matrix |
viewport | 4D vector for window viewport (most likely { 0, 0, SCREEN_WIDTH, SCREEN_WIDTH }) |