Reimplementation

This commit is contained in:
2015-10-25 12:31:41 -07:00
parent cd3d2ee133
commit dbbd3c76ef
26 changed files with 250 additions and 129 deletions

View File

@@ -136,18 +136,19 @@ CQuaternion CQuaternion::inverse() const
CAxisAngle CQuaternion::toAxisAngle()
{
CAxisAngle ret;
ret.angle = acosf(r);
// CAxisAngle ret;
// ret.angle = acosf(r);
float thetaInv = 1.0f/sinf(ret.angle);
// float thetaInv = 1.0f/sinf(ret.angle);
ret.axis.x = v.x * thetaInv;
ret.axis.y = v.y * thetaInv;
ret.axis.z = v.z * thetaInv;
// ret.axis.x = v.x * thetaInv;
// ret.axis.y = v.y * thetaInv;
// ret.axis.z = v.z * thetaInv;
ret.angle *= 2;
// ret.angle *= 2;
return ret;
// return ret;
return CAxisAngle();
}
CQuaternion CQuaternion::log() const

View File

@@ -18,7 +18,8 @@ float CVector2f::getAngleDiff(const CVector2f& a, const CVector2f& b)
if (!mag1 || !mag2)
return 0;
float theta = acosf(a.dot(b) / (mag1 * mag2));
float dot = a.dot(b);
float theta = Math::arcCosineR(dot / (mag1 * mag2));
return theta;
}

View File

@@ -18,7 +18,8 @@ float CVector3f::getAngleDiff(const CVector3f& a, const CVector3f& b)
if (!mag1 || !mag2)
return 0;
float theta = acosf(a.dot(b) / (mag1 * mag2));
float dot = a.dot(b);
float theta = Math::arcCosineR(dot / (mag1 * mag2));
return theta;
}

View File

@@ -1,4 +1,6 @@
#include "Math.hpp"
#include "CTransform.hpp"
#include "CVector3f.hpp"
namespace Zeus
{
@@ -239,5 +241,12 @@ CVector3f getRoundCatmullRomSplinePoint(const CVector3f& a, const CVector3f& b,
return getCatmullRomSplinePoint(b, c, bVelocity * cbDistance, cVelocity * cbDistance, t);
}
CVector3f baryToWorld(const CVector3f& p0, const CVector3f& p1, const CVector3f& p2, const CVector3f& bary)
{ return bary.x * p0 + bary.y * p1 + bary.z * p2; }
CVector3f radToDeg(const CVector3f& rad) {return rad * kRadToDegVec;}
CVector3f degToRad(const CVector3f& deg) {return deg * kDegToRadVec;}
}
}