From 0b67ecf0735ffb2467b6d25d4f85950bab79504b Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sun, 30 Jul 2017 00:43:44 -0700 Subject: [PATCH] Add `MakeRotationsBasedOnY` to CTransform --- include/zeus/CTransform.hpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/zeus/CTransform.hpp b/include/zeus/CTransform.hpp index 3edcecf..3bf23bd 100644 --- a/include/zeus/CTransform.hpp +++ b/include/zeus/CTransform.hpp @@ -5,6 +5,7 @@ #include "zeus/CMatrix3f.hpp" #include "zeus/CMatrix4f.hpp" #include "zeus/CVector3f.hpp" +#include "zeus/CUnitVector.hpp" #include #include @@ -246,6 +247,20 @@ public: 0.f, 0.f, 0.f, 1.f); } + static zeus::CTransform MakeRotationsBasedOnY(const CUnitVector3f& uVec) + { + uint32_t i; + if (uVec.y < uVec.x || uVec.z < uVec.y || uVec.z < uVec.x) + i = 2; + else + i = 1; + + CVector3f v = CVector3f::skZero; + v[i] = 1.f; + CUnitVector3f newUVec(uVec.cross(v)); + return {newUVec, uVec, uVec.cross(newUVec), CVector3f::skZero}; + } + CMatrix3f basis; CVector3f origin; };