matrix: add affine definitions and translate impl

This commit is contained in:
Danny Robson 2014-12-15 13:45:17 +11:00
parent d51caee0c7
commit 2fc9073901
2 changed files with 19 additions and 0 deletions

View File

@ -501,6 +501,20 @@ matrix<T>::look_at (util::point<3> eye,
}
//-----------------------------------------------------------------------------
template <typename T>
matrix<T>
matrix<T>::translate (util::vector<3> v)
{
return { {
{ 1.f, 0.f, 0.f, v.x },
{ 0.f, 1.f, 0.f, v.y },
{ 0.f, 0.f, 1.f, v.z },
{ 0.f, 0.f, 0.f, 1.f },
} };
}
//-----------------------------------------------------------------------------
template <typename T>
const matrix<T>

View File

@ -65,6 +65,11 @@ namespace util {
static matrix<T> perspective (T fov, T aspect, T near, T far);
static matrix<T> look_at (util::point<3> eye, util::point<3> centre, util::vector<3> up);
// Affine matrices
static matrix<T> translate (util::vector<3>);
static matrix<T> scale (util::vector<3>);
static matrix<T> rotate (util::vector<3> about, T angle);
// Constant matrices
static const matrix<T> IDENTITY;
static const matrix<T> ZEROES;