From bd2e84521b185467db02d75109c989d663df88be Mon Sep 17 00:00:00 2001 From: ganovelli Date: Thu, 22 Jun 2006 08:00:26 +0000 Subject: [PATCH] toMatrix with matrix33 added --- vcg/math/quaternion.h | 55 +++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/vcg/math/quaternion.h b/vcg/math/quaternion.h index 74a5be64..ee53c23b 100644 --- a/vcg/math/quaternion.h +++ b/vcg/math/quaternion.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.14 2005/04/17 21:57:03 ganovelli +tolto il const a interpolate + Revision 1.13 2005/04/15 09:19:50 ponchio Typo: Point3 -> Point4 @@ -47,6 +50,9 @@ updated access to matrix44 elements through V() instead simple [] Revision 1.6 2004/03/25 14:57:49 ponchio Microerror. ($LOG$ -> $Log: not supported by cvs2svn $ +Microerror. ($LOG$ -> Revision 1.14 2005/04/17 21:57:03 ganovelli +Microerror. ($LOG$ -> tolto il const a interpolate +Microerror. ($LOG$ -> Microerror. ($LOG$ -> Revision 1.13 2005/04/15 09:19:50 ponchio Microerror. ($LOG$ -> Typo: Point3 -> Point4 Microerror. ($LOG$ -> @@ -80,6 +86,7 @@ Microerror. ($LOG$ -> #include #include #include +#include namespace vcg { @@ -110,6 +117,7 @@ public: void FromMatrix(Matrix44 &m); void ToMatrix(Matrix44 &m) const; + void ToMatrix(Matrix33 &m) const; Point3 Rotate(const Point3 vec) const; //duplicated ... because of gcc new confoming to ISO template derived classes @@ -225,28 +233,7 @@ template void Quaternion::ToMatrix(Matrix44 &m) const { S q22 = V(3)*V(3); S q23 = V(3)*V(0); -/* <<<<<<< quaternion.h - m[0][ 0] = (S)(1.0-(q11 + q22)*2.0); - m[1][ 0] = (S)((q01 - q23)*2.0); - m[2][ 0] = (S)((q02 + q13)*2.0); - m[3][ 0] = (S)0.0; - - m[0][ 1] = (S)((q01 + q23)*2.0); - m[1][ 1] = (S)(1.0-(q22 + q00)*2.0); - m[2][ 1] = (S)((q12 - q03)*2.0); - m[3][ 1] = (S)0.0; - - m[0][ 2] = (S)((q02 - q13)*2.0); - m[1][ 2] = (S)((q12 + q03)*2.0); - m[2][ 2] = (S)(1.0-(q11 + q00)*2.0); - m[3][ 2] = (S)0.0; - - m[0][ 3] = (S)0.0; - m[1][ 3] = (S)0.0; - m[2][ 3] = (S)0.0; - m[3][ 3] = (S)1.0; -=======*/ - m[0][0] = (S)(1.0-(q11 + q22)*2.0); + m[0][0] = (S)(1.0-(q11 + q22)*2.0); m[1][0] = (S)((q01 - q23)*2.0); m[2][0] = (S)((q02 + q13)*2.0); m[3][0] = (S)0.0; @@ -265,10 +252,32 @@ template void Quaternion::ToMatrix(Matrix44 &m) const { m[1][3] = (S)0.0; m[2][3] = (S)0.0; m[3][3] = (S)1.0; -//>>>>>>> 1.9 } +template void Quaternion::ToMatrix(Matrix33 &m) const { + S q00 = V(1)*V(1); + S q01 = V(1)*V(2); + S q02 = V(1)*V(3); + S q03 = V(1)*V(0); + S q11 = V(2)*V(2); + S q12 = V(2)*V(3); + S q13 = V(2)*V(0); + S q22 = V(3)*V(3); + S q23 = V(3)*V(0); + m[0][0] = (S)(1.0-(q11 + q22)*2.0); + m[1][0] = (S)((q01 - q23)*2.0); + m[2][0] = (S)((q02 + q13)*2.0); + + m[0][1] = (S)((q01 + q23)*2.0); + m[1][1] = (S)(1.0-(q22 + q00)*2.0); + m[2][1] = (S)((q12 - q03)*2.0); + + m[0][2] = (S)((q02 - q13)*2.0); + m[1][2] = (S)((q12 + q03)*2.0); + m[2][2] = (S)(1.0-(q11 + q00)*2.0); +} + ///warning m deve essere una matrice di rotazione pena il disastro. template void Quaternion::FromMatrix(Matrix44 &m) { S Sc;