|
From: <axl...@us...> - 2009-05-26 01:14:36
|
Revision: 274
http://hgengine.svn.sourceforge.net/hgengine/?rev=274&view=rev
Author: axlecrusher
Date: 2009-05-26 00:27:12 +0000 (Tue, 26 May 2009)
Log Message:
-----------
fix bug
Modified Paths:
--------------
Mercury2/src/MQuaternion.cpp
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2009-05-22 01:31:33 UTC (rev 273)
+++ Mercury2/src/MQuaternion.cpp 2009-05-26 00:27:12 UTC (rev 274)
@@ -3,10 +3,10 @@
MQuaternion::MQuaternion(float W, float X, float Y, float Z)
{
- m_xyzw[3] = X;
- m_xyzw[0] = Y;
- m_xyzw[1] = Z;
- m_xyzw[2] = W;
+ m_xyzw[0] = X;
+ m_xyzw[1] = Y;
+ m_xyzw[2] = Z;
+ m_xyzw[3] = W;
}
MQuaternion::MQuaternion(float* xyzw)
@@ -25,14 +25,7 @@
float & MQuaternion::operator [] (int i)
{
- switch (i)
- {
- case 0: return m_xyzw[0];
- case 1: return m_xyzw[1];
- case 2: return m_xyzw[2];
- case 3: return m_xyzw[3];
- }
- return m_xyzw[0]; //haha we won't even get here.
+ return m_xyzw[i];
}
void MQuaternion::SetEuler(const MercuryVector& angles)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-05-31 01:25:49
|
Revision: 284
http://hgengine.svn.sourceforge.net/hgengine/?rev=284&view=rev
Author: axlecrusher
Date: 2009-05-31 01:25:41 +0000 (Sun, 31 May 2009)
Log Message:
-----------
start zeroed
Modified Paths:
--------------
Mercury2/src/MQuaternion.cpp
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2009-05-31 01:24:34 UTC (rev 283)
+++ Mercury2/src/MQuaternion.cpp 2009-05-31 01:25:41 UTC (rev 284)
@@ -3,7 +3,7 @@
MQuaternion::MQuaternion()
{
- m_wxyz[0] = 1;
+ m_wxyz[0] = 0;
m_wxyz[1] = 0;
m_wxyz[2] = 0;
m_wxyz[3] = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-04 01:22:27
|
Revision: 304
http://hgengine.svn.sourceforge.net/hgengine/?rev=304&view=rev
Author: axlecrusher
Date: 2009-06-04 00:29:27 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
we MUST normalize before multiplying
Modified Paths:
--------------
Mercury2/src/MQuaternion.cpp
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2009-06-04 00:11:52 UTC (rev 303)
+++ Mercury2/src/MQuaternion.cpp 2009-06-04 00:29:27 UTC (rev 304)
@@ -180,11 +180,14 @@
MQuaternion MQuaternion::operator * (const MQuaternion &rhs) const
{
+ MQuaternion q1( this->normalize() );
+ MQuaternion q2( rhs.normalize() );
+
MQuaternion result;
- result.m_wxyz[0] = (m_wxyz[0]*rhs.m_wxyz[0])-(m_wxyz[1]*rhs.m_wxyz[1])-(m_wxyz[2]*rhs.m_wxyz[2])-(m_wxyz[3]*rhs.m_wxyz[3]);
- result.m_wxyz[1] = (m_wxyz[0]*rhs.m_wxyz[1])+(m_wxyz[1]*rhs.m_wxyz[0])+(m_wxyz[2]*rhs.m_wxyz[3])-(m_wxyz[3]*rhs.m_wxyz[2]);
- result.m_wxyz[2] = (m_wxyz[0]*rhs.m_wxyz[2])-(m_wxyz[1]*rhs.m_wxyz[3])+(m_wxyz[2]*rhs.m_wxyz[0])+(m_wxyz[3]*rhs.m_wxyz[1]);
- result.m_wxyz[3] = (m_wxyz[0]*rhs.m_wxyz[3])+(m_wxyz[1]*rhs.m_wxyz[2])-(m_wxyz[2]*rhs.m_wxyz[1])+(m_wxyz[3]*rhs.m_wxyz[0]);
+ result.W() = (q1.W()*q2.W())-(q1.X()*q2.X())-(q1.Y()*q2.Y())-(q1.Z()*q2.Z());
+ result.X() = (q1.W()*q2.X())+(q1.X()*q2.W())+(q1.Y()*q2.Z())-(q1.Z()*q2.Y());
+ result.Y() = (q1.W()*q2.Y())-(q1.X()*q2.Z())+(q1.Y()*q2.W())+(q1.Z()*q2.X());
+ result.Z() = (q1.W()*q2.Z())+(q1.X()*q2.Y())-(q1.Y()*q2.X())+(q1.Z()*q2.W());
return result;
}
@@ -208,10 +211,7 @@
}
MQuaternion& MQuaternion::operator *= (const MQuaternion &rhs) {
- m_wxyz[0] = (m_wxyz[0]*rhs.m_wxyz[0])-(m_wxyz[1]*rhs.m_wxyz[1])-(m_wxyz[2]*rhs.m_wxyz[2])-(m_wxyz[3]*rhs.m_wxyz[3]);
- m_wxyz[1] = (m_wxyz[0]*rhs.m_wxyz[1])+(m_wxyz[1]*rhs.m_wxyz[0])+(m_wxyz[2]*rhs.m_wxyz[3])-(m_wxyz[3]*rhs.m_wxyz[2]);
- m_wxyz[2] = (m_wxyz[0]*rhs.m_wxyz[2])-(m_wxyz[1]*rhs.m_wxyz[3])+(m_wxyz[2]*rhs.m_wxyz[0])+(m_wxyz[3]*rhs.m_wxyz[1]);
- m_wxyz[3] = (m_wxyz[0]*rhs.m_wxyz[3])+(m_wxyz[1]*rhs.m_wxyz[2])-(m_wxyz[2]*rhs.m_wxyz[1])+(m_wxyz[3]*rhs.m_wxyz[0]);
+ *this = *this * rhs;
return (*this);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-04-27 18:16:57
|
Revision: 704
http://hgengine.svn.sourceforge.net/hgengine/?rev=704&view=rev
Author: axlecrusher
Date: 2010-04-27 18:16:51 +0000 (Tue, 27 Apr 2010)
Log Message:
-----------
const reference
Modified Paths:
--------------
Mercury2/src/MQuaternion.cpp
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2010-04-27 18:16:10 UTC (rev 703)
+++ Mercury2/src/MQuaternion.cpp 2010-04-27 18:16:51 UTC (rev 704)
@@ -275,7 +275,7 @@
}
//Returns the Euclidian Outer Product of two MQuaternions
-MercuryVertex outerProduct(MQuaternion a,MQuaternion b)
+MercuryVertex outerProduct(const MQuaternion& a, const MQuaternion& b)
{
MercuryVertex result;
result[0] = (a.m_wxyz[0]*b.m_wxyz[1])-(a.m_wxyz[1]*b.m_wxyz[0])-(a.m_wxyz[2]*b.m_wxyz[3])+(a.m_wxyz[3]*b.m_wxyz[2]);
@@ -285,7 +285,7 @@
}
//Returns the Even Product of two MQuaternions
-MQuaternion evenProduct(MQuaternion a,MQuaternion b) {
+MQuaternion evenProduct(const MQuaternion& a, const MQuaternion& b) {
MQuaternion result;
result.m_wxyz[0] = (a.m_wxyz[0]*b.m_wxyz[0])-(a.m_wxyz[1]*b.m_wxyz[1])-(a.m_wxyz[2]*b.m_wxyz[2])-(a.m_wxyz[3]*b.m_wxyz[3]);
result.m_wxyz[1] = (a.m_wxyz[0]*b.m_wxyz[1])+(a.m_wxyz[1]*b.m_wxyz[0]);
@@ -295,7 +295,7 @@
}
//Returns the Odd Product of two MQuaternions (Similar to Vector Cross-Product)
-MercuryVertex oddProduct(MQuaternion a,MQuaternion b) {
+MercuryVertex oddProduct(const MQuaternion& a, const MQuaternion& b) {
MercuryVertex result;
result[0] = (a.m_wxyz[2]*b.m_wxyz[3])-(a.m_wxyz[3]*b.m_wxyz[2]);
result[1] = (a.m_wxyz[3]*b.m_wxyz[1])-(a.m_wxyz[1]*b.m_wxyz[3]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|