matrix: add affine definitions and translate impl
This commit is contained in:
parent
d51caee0c7
commit
2fc9073901
14
matrix.cpp
14
matrix.cpp
@ -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>
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user