Helper functions for CTransform and CQuaternion

This commit is contained in:
Phillip Stephens 2016-09-13 22:10:36 -07:00
parent 841e25df42
commit d03f1157dd
2 changed files with 17 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include "zeus/CMatrix3f.hpp" #include "zeus/CMatrix3f.hpp"
#include "zeus/Math.hpp" #include "zeus/Math.hpp"
#include "zeus/CRelAngle.hpp" #include "zeus/CRelAngle.hpp"
#include "zeus/CTransform.hpp"
#if ZE_ATHENA_TYPES #if ZE_ATHENA_TYPES
#include <athena/IStreamReader.hpp> #include <athena/IStreamReader.hpp>
#endif #endif
@ -186,6 +187,7 @@ public:
CQuaternion exp() const; CQuaternion exp() const;
inline CTransform toTransform() const { return CTransform(CMatrix3f(*this)); }
float dot(const CQuaternion& quat) const; float dot(const CQuaternion& quat) const;
static CQuaternion lerp(const CQuaternion& a, const CQuaternion& b, double t); static CQuaternion lerp(const CQuaternion& a, const CQuaternion& b, double t);

View File

@ -5,7 +5,6 @@
#include "zeus/CMatrix3f.hpp" #include "zeus/CMatrix3f.hpp"
#include "zeus/CMatrix4f.hpp" #include "zeus/CMatrix4f.hpp"
#include "zeus/CVector3f.hpp" #include "zeus/CVector3f.hpp"
#include "zeus/CQuaternion.hpp"
namespace zeus namespace zeus
{ {
@ -201,6 +200,21 @@ public:
return ret; return ret;
} }
inline CVector3f upVector() const
{
return { basis.m[2][0], basis.m[2][1], basis.m[2][2] };
}
inline CVector3f frontVector() const
{
return { basis.m[1][0], basis.m[1][1], basis.m[1][2] };
}
inline CVector3f rightVector() const
{
return { basis.m[0][0], basis.m[0][1], basis.m[0][2] };
}
static inline CTransform fromColumns(const CVector3f& m0, const CVector3f& m1, const CVector3f& m2, const CVector3f& m3) static inline CTransform fromColumns(const CVector3f& m0, const CVector3f& m1, const CVector3f& m2, const CVector3f& m3)
{ {
CTransform ret; CTransform ret;