Added more debugging and option to disable new streflop usage.

This commit is contained in:
Mark Vejvoda
2010-05-01 20:14:25 +00:00
parent 2417f37e21
commit 04bb6659ce
28 changed files with 447 additions and 112 deletions

View File

@@ -9,7 +9,7 @@
// License, or (at your option) any later version
// ==============================================================
#include "streflop_cond.h"
#include "math_wrapper.h"
#include "quaternion.h"
#include "leak_dumper.h"
@@ -67,15 +67,23 @@ void Quaternion::setAddIdentity(){
}
void Quaternion::setAxisAngle(const AxisAngle &axisAngle){
#ifdef USE_STREFLOP
w= streflop::cosf(axisAngle.angle/2.0f);
v.x= axisAngle.axis.x * streflop::sinf(axisAngle.angle/2.0f);
v.y= axisAngle.axis.y * streflop::sinf(axisAngle.angle/2.0f);
v.z= axisAngle.axis.z * streflop::sinf(axisAngle.angle/2.0f);
#else
w= cosf(axisAngle.angle/2.0f);
v.x= axisAngle.axis.x * sinf(axisAngle.angle/2.0f);
v.y= axisAngle.axis.y * sinf(axisAngle.angle/2.0f);
v.z= axisAngle.axis.z * sinf(axisAngle.angle/2.0f);
#endif
}
void Quaternion::setEuler(const EulerAngles &eulerAngles){
Quaternion qx, qy, qz, qr;
#ifdef USE_STREFLOP
qx.w= streflop::cosf(eulerAngles.x/2.0f);
qx.v= Vec3f(streflop::sinf(eulerAngles.x/2.0f), 0.0f, 0.0f);
@@ -84,6 +92,16 @@ void Quaternion::setEuler(const EulerAngles &eulerAngles){
qz.w= streflop::cosf(eulerAngles.z/2.0f);
qz.v= Vec3f(0.0f, 0.0f, streflop::sinf(eulerAngles.z/2.0f));
#else
qx.w= cosf(eulerAngles.x/2.0f);
qx.v= Vec3f(sinf(eulerAngles.x/2.0f), 0.0f, 0.0f);
qy.w= cosf(eulerAngles.y/2.0f);
qy.v= Vec3f(0.0f, sinf(eulerAngles.y/2.0f), 0.0f);
qz.w= cosf(eulerAngles.z/2.0f);
qz.v= Vec3f(0.0f, 0.0f, sinf(eulerAngles.z/2.0f));
#endif
qr= qx*qy*qz;
@@ -92,7 +110,11 @@ void Quaternion::setEuler(const EulerAngles &eulerAngles){
}
float Quaternion::length(){
#ifdef USE_STREFLOP
return streflop::sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z);
#else
return sqrt(w*w+v.x*v.x+v.y*v.y+v.z*v.z);
#endif
}
Quaternion Quaternion::conjugate(){
@@ -184,7 +206,11 @@ Matrix4f Quaternion::toMatrix4() const{
AxisAngle Quaternion::toAxisAngle() const{
float scale= 1.0f/(v.x*v.x + v.y*v.y + v.z*v.z);
#ifdef USE_STREFLOP
return AxisAngle(v*scale, 2*streflop::acosf(w));
#else
return AxisAngle(v*scale, 2*acosf(w));
#endif
}
Vec3f Quaternion::getLocalXAxis() const{