philsupertramp/game-math
Loading...
Searching...
No Matches
Functions
Math::Utils Namespace Reference

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 > &center, 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)
 

Function Documentation

◆ angleAxis()

template<class T >
mat4< T > Math::Utils::angleAxis ( const float &  angle,
const vec3< T > &  axis 
)
Template Parameters
T
Parameters
angle
axis
Returns
Examples
TestUtils.cpp.

◆ distance()

template<class V >
float Math::Utils::distance ( const V &  a,
const V &  b 
)

Calculates distance between given vectors

Template Parameters
V
Parameters
a
b
Returns
Examples
TestUtils.cpp.

◆ lerp() [1/2]

template<class T >
vec3< T > Math::Utils::lerp ( const vec3< T > &  p1,
const vec3< T > &  p2,
const float &  v 
)

linear interpolates a 3D-vector by given values

Template Parameters
T
Parameters
p1
p2
v
Returns
Examples
TestUtils.cpp.

◆ lerp() [2/2]

template<class T >
vec4< T > Math::Utils::lerp ( const vec4< T > &  p1,
const vec4< T > &  p2,
const float &  v 
)

linear interpolates a 4D-vector by given values

Template Parameters
T
Parameters
p1
p2
v
Returns

◆ lookAt()

template<class T >
mat4< T > Math::Utils::lookAt ( const vec3< T > &  eye,
const vec3< T > &  center,
const vec3< T > &  up 
)

Computes look at matrix for given data

Template Parameters
T
Parameters
eye
center
up
Returns
Examples
TestUtils.cpp.

◆ max()

template<class T >
vec3< T > Math::Utils::max ( const vec3< T > &  a,
const vec3< T > &  b 
)

Computes max-value between two given 3D-vectors

Template Parameters
T
Parameters
a
b
Returns
Examples
TestUtils.cpp.

◆ normalize() [1/3]

template<class T >
vec2< T > Math::Utils::normalize ( const vec2< T > &  a)

helper to normalize 2D-vector

Template Parameters
T
Parameters
a
Returns
Examples
TestUtils.cpp.

◆ normalize() [2/3]

template<class T >
vec3< T > Math::Utils::normalize ( const vec3< T > &  a)

helper to normalize 3D-vector

Template Parameters
T
Parameters
a
Returns

◆ normalize() [3/3]

template<class T >
vec4< T > Math::Utils::normalize ( const vec4< T > &  a)

helper to normalize 4D-vector

Template Parameters
T
Parameters
a
Returns

◆ ortho()

template<class T >
mat4< T > Math::Utils::ortho ( const float &  left,
const float &  right,
const float &  bottom,
const float &  top 
)

calculates orthogonal projection plane

Template Parameters
T
Parameters
left
right
bottom
top
Returns

◆ perspective()

template<class T >
mat4< T > Math::Utils::perspective ( const float &  FOV,
const float &  width,
const float &  height,
const float &  zNear,
const float &  zFar 
)

Computes perspective projection matrix

Template Parameters
T
Parameters
FOV
width
height
zNear
zFar
Returns

◆ rotate()

template<class T >
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

Template Parameters
T
Parameters
m
angle
u
Returns
Examples
TestUtils.cpp.

◆ scale() [1/2]

template<class T >
mat4< T > Math::Utils::scale ( const mat4< T > &  mat,
const float &  factor 
)

scales a given matrix by a factor

Template Parameters
T
Parameters
mat
factor
Returns
Examples
TestUtils.cpp.

◆ scale() [2/2]

template<class T >
mat4< T > Math::Utils::scale ( const mat4< T > &  mat,
const vec3< T > &  factor 
)

◆ translate()

template<class T >
mat4< T > Math::Utils::translate ( const mat4< T > &  M,
const vec3< T > &  V 
)

Translates a given 4-by-4 matrix M by given vector V

Template Parameters
T
Parameters
M
V
Returns
Examples
TestUtils.cpp.

◆ unProject()

template<typename T , typename U >
vec3< T > Math::Utils::unProject ( vec3< T > const &  win,
mat4< T > const &  model,
mat4< T > const &  proj,
vec4< U > const &  viewport 
)

Inverts projection

Template Parameters
T
U
Parameters
win3D point to convert from window space
model(model * view)-matrix
projprojection matrix
viewport4D vector for window viewport (most likely { 0, 0, SCREEN_WIDTH, SCREEN_WIDTH })
Returns