From 5551fccc5dc264a20f3fe28c22868252555454de Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 1 Apr 2017 17:03:04 -1000 Subject: [PATCH] CMatrix3f Rotation constructors --- include/zeus/CMatrix3f.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/zeus/CMatrix3f.hpp b/include/zeus/CMatrix3f.hpp index 21d9507..5034d73 100644 --- a/include/zeus/CMatrix3f.hpp +++ b/include/zeus/CMatrix3f.hpp @@ -187,6 +187,30 @@ public: vec[2] += other.vec[2] * scaleVec; } + static inline CMatrix3f RotateX(float theta) + { + float sinT = std::sin(theta); + float cosT = std::cos(theta); + return CMatrix3f(TVectorUnion{1.f, 0.f, 0.f, 0.f}, TVectorUnion{0.f, cosT, sinT, 0.f}, + TVectorUnion{0.f, -sinT, cosT, 0.f}); + } + + static inline CMatrix3f RotateY(float theta) + { + float sinT = std::sin(theta); + float cosT = std::cos(theta); + return CMatrix3f(TVectorUnion{cosT, 0.f, -sinT, 0.f}, TVectorUnion{0.f, 1.f, 0.f, 0.f}, + TVectorUnion{sinT, 0.f, cosT, 0.f}); + } + + static inline CMatrix3f RotateZ(float theta) + { + float sinT = std::sin(theta); + float cosT = std::cos(theta); + return CMatrix3f(TVectorUnion{cosT, sinT, 0.f, 0.f}, TVectorUnion{-sinT, cosT, 0.f, 0.f}, + TVectorUnion{0.f, 0.f, 1.f, 0.f}); + } + union { float m[3][4]; /* 4th row for union-alignment */ struct