diff --git a/matrix.cpp b/matrix.cpp index 61f64fcc..63f05fa6 100644 --- a/matrix.cpp +++ b/matrix.cpp @@ -501,6 +501,20 @@ matrix::look_at (util::point<3> eye, } +//----------------------------------------------------------------------------- +template +matrix +matrix::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 const matrix diff --git a/matrix.hpp b/matrix.hpp index f3270586..cd29ab68 100644 --- a/matrix.hpp +++ b/matrix.hpp @@ -65,6 +65,11 @@ namespace util { static matrix perspective (T fov, T aspect, T near, T far); static matrix look_at (util::point<3> eye, util::point<3> centre, util::vector<3> up); + // Affine matrices + static matrix translate (util::vector<3>); + static matrix scale (util::vector<3>); + static matrix rotate (util::vector<3> about, T angle); + // Constant matrices static const matrix IDENTITY; static const matrix ZEROES;