diff --git a/vcg/math/matrix33.h b/vcg/math/matrix33.h index 8ec25a66..5fad623d 100644 --- a/vcg/math/matrix33.h +++ b/vcg/math/matrix33.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.8 2005/06/10 14:51:54 cignoni +Changed a Zero in SetZero in WeightedCrossCovariance() + Revision 1.7 2005/06/10 11:46:49 pietroni Added Norm Function @@ -56,6 +59,7 @@ created #define __VCGLIB_MATRIX33_H #include +#include #include #include @@ -70,6 +74,7 @@ public: @param S (Templete Parameter) Specifies the ScalarType field. */ Matrix33Diag(const S & p0,const S & p1,const S & p2):Point3(p0,p1,p2){}; + Matrix33Diag(const Point3&p ):Point3(p){}; }; template @@ -180,6 +185,38 @@ public: return r; } + /// Modificatore prodotto per matrice + void operator *=( const Matrix33< S> & t ) + { + int i,j; + for(i=0;i<3;++i) + for(j=0;j<3;++j) + (*this)[i][j] = (*this)[i][0]*t[0][j] + (*this)[i][1]*t[1][j] + (*this)[i][2]*t[2][j]; + + } + + /// Dot product with a diagonal matrix + Matrix33 operator * ( const Matrix33Diag< S> & t ) const + { + Matrix33 r; + + int i,j; + for(i=0;i<3;++i) + for(j=0;j<3;++j) + r[i][j] = (*this)[i][j]*t[j]; + + return r; + } + + /// Dot product modifier with a diagonal matrix + void operator *=( const Matrix33Diag< S> & t ) + { + int i,j; + for(i=0;i<3;++i) + for(j=0;j<3;++j) + (*this)[i][j] = (*this)[i][j]*t[j]; + } + /// Modificatore prodotto per costante Matrix33 & operator *= ( const S t ) { @@ -459,6 +496,27 @@ private: S a[9]; }; +template +void Invert(Matrix33 &m) + { + Matrix33 v; + Point3::ScalarType> e; + SingularValueDecomposition(m,&e[0],v); + e[0]=1/e[0];e[1]=1/e[1];e[2]=1/e[2]; + m.Transpose(); + m = v * Matrix33Diag(e) * m; + } + +template +Matrix33 Inverse(const Matrix33&m) + { + Matrix33 v,m_copy=m; + Point3 e; + SingularValueDecomposition(m_copy,&e[0],v); + m_copy.Transpose(); + e[0]=1/e[0];e[1]=1/e[1];e[2]=1/e[2]; + return v * MatrixDiag(e) * m_copy; + } /// typedef Matrix33 Matrix33s;