toMatrix with matrix33 added

This commit is contained in:
ganovelli 2006-06-22 08:00:26 +00:00
parent 9587cc0350
commit bd2e84521b
1 changed files with 32 additions and 23 deletions

View File

@ -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 <vcg/space/point4.h>
#include <vcg/math/base.h>
#include <vcg/math/matrix44.h>
#include <vcg/math/matrix33.h>
namespace vcg {
@ -110,6 +117,7 @@ public:
void FromMatrix(Matrix44<S> &m);
void ToMatrix(Matrix44<S> &m) const;
void ToMatrix(Matrix33<S> &m) const;
Point3<S> Rotate(const Point3<S> vec) const;
//duplicated ... because of gcc new confoming to ISO template derived classes
@ -225,28 +233,7 @@ template <class S> void Quaternion<S>::ToMatrix(Matrix44<S> &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 <class S> void Quaternion<S>::ToMatrix(Matrix44<S> &m) const {
m[1][3] = (S)0.0;
m[2][3] = (S)0.0;
m[3][3] = (S)1.0;
//>>>>>>> 1.9
}
template <class S> void Quaternion<S>::ToMatrix(Matrix33<S> &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 <class S> void Quaternion<S>::FromMatrix(Matrix44<S> &m) {
S Sc;