From e4eb234889255e65318e66a53372e34ed9768eac Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 24 Jul 2020 13:44:32 +1000 Subject: [PATCH] matrix: add `rotation_euler` conversion --- matrix.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/matrix.hpp b/matrix.hpp index e5d8c02d..d6bf4502 100644 --- a/matrix.hpp +++ b/matrix.hpp @@ -245,6 +245,19 @@ namespace cruft { //template matrix<4,4,T> scale (T); template matrix<4,4,T> rotation (T angle, vector<3,T> about); + + /// Returns a matrix representing the rotation vector specifying the + /// concatentation of: {yaw,pitch,roll}. + template + constexpr + matrix<4,4,ValueT> + rotation_euler (vector<3,ValueT> angles) + { + return rotation (angles[1], {0,1,0}) * + rotation (angles[0], {1,0,0}) * + rotation (angles[2], {0,0,1}); + } + //template matrix<3,3,T> translation (vector<2,T>); //template matrix<3,3,T> scale (vector<2,T>);