From 19675a4e33b35f7482bc9f323f64306baeb7b5bd Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 11 Oct 2012 10:48:55 +0000 Subject: [PATCH] Deprecating the use of old dangerous linear algebra code. Please use Eigen! Now attempting to include lin_algebra will block your compilation... --- vcg/math/deprecated_matrix.h | 31 +++++++++++++++---------------- vcg/math/deprecated_matrix33.h | 15 ++++++++++++++- vcg/math/deprecated_matrix44.h | 8 ++++++++ vcg/math/lin_algebra.h | 4 +++- vcg/space/deprecated_point3.h | 8 +++++++- vcg/space/deprecated_point4.h | 10 +++++++++- 6 files changed, 56 insertions(+), 20 deletions(-) diff --git a/vcg/math/deprecated_matrix.h b/vcg/math/deprecated_matrix.h index e1057c74..e9e4b564 100644 --- a/vcg/math/deprecated_matrix.h +++ b/vcg/math/deprecated_matrix.h @@ -50,7 +50,6 @@ added diagonal matrix, outer produce and namespace #include #include #include -#include namespace vcg{ namespace ndim{ @@ -764,22 +763,22 @@ namespace vcg{ /*! @} */ - template - void Invert(MatrixType & m){ - typedef typename MatrixType::ScalarType X; - X *diag; - diag = new X [m.ColumnsNumber()]; +// template +// void Invert(MatrixType & m){ +// typedef typename MatrixType::ScalarType X; +// X *diag; +// diag = new X [m.ColumnsNumber()]; - MatrixType res(m.RowsNumber(),m.ColumnsNumber()); - vcg::SingularValueDecomposition (m,&diag[0],res,LeaveUnsorted,50 ); - m.Transpose(); - // prodotto per la diagonale - unsigned int i,j; - for (i=0; i (m,&diag[0],res,LeaveUnsorted,50 ); +// m.Transpose(); +// // prodotto per la diagonale +// unsigned int i,j; +// for (i=0; i -#include #include #include #include @@ -151,6 +150,20 @@ public: } } + template + void ToEigenMatrix(EigenMatrix33Type & m){ + for(int i = 0; i < 3; i++) + for(int j = 0; j < 3; j++) + m(i,j)=(*this)[i][j]; + } + + template + void FromEigenMatrix(const EigenMatrix33Type & m){ + for(int i = 0; i < 3; i++) + for(int j = 0; j < 3; j++) + (*this)[i][j]=m(i,j); + } + /// Number of columns inline unsigned int ColumnsNumber() const { diff --git a/vcg/math/deprecated_matrix44.h b/vcg/math/deprecated_matrix44.h index a077ed71..f72e40b7 100644 --- a/vcg/math/deprecated_matrix44.h +++ b/vcg/math/deprecated_matrix44.h @@ -247,6 +247,14 @@ public: template void FromMatrix(const Matrix44Type & m){for(int i = 0; i < 16; i++) V()[i]=m.V()[i];} + + template + void FromEigenMatrix(const EigenMatrix44Type & m){ + for(int i = 0; i < 4; i++) + for(int j = 0; j < 4; j++) + ElementAt(i,j)=m(i,j); + } + void FromEulerAngles(T alpha, T beta, T gamma); void SetZero(); void SetIdentity(); diff --git a/vcg/math/lin_algebra.h b/vcg/math/lin_algebra.h index 45cd324a..bda37487 100644 --- a/vcg/math/lin_algebra.h +++ b/vcg/math/lin_algebra.h @@ -52,7 +52,9 @@ Added initial disclaimer #include #include #include - +#ifndef _YES_I_WANT_TO_USE_DANGEROUS_STUFF +#error "Please do not never user this file. Use EIGEN!!!!" +#endif namespace vcg { /** \addtogroup math */ diff --git a/vcg/space/deprecated_point3.h b/vcg/space/deprecated_point3.h index 71eb9e89..e905e51a 100644 --- a/vcg/space/deprecated_point3.h +++ b/vcg/space/deprecated_point3.h @@ -172,7 +172,13 @@ public: _v[1] = P3ScalarType(b[1]); _v[2] = P3ScalarType(b[2]); } - + template + inline void FromEigenVector( const EigenVector & b ) + { + _v[0] = P3ScalarType(b[0]); + _v[1] = P3ScalarType(b[1]); + _v[2] = P3ScalarType(b[2]); + } template static inline Point3 Construct( const Point3 & b ) { diff --git a/vcg/space/deprecated_point4.h b/vcg/space/deprecated_point4.h index 26437d2c..134f408a 100644 --- a/vcg/space/deprecated_point4.h +++ b/vcg/space/deprecated_point4.h @@ -113,7 +113,15 @@ public: _v[2] = T(b[2]); _v[3] = T(b[3]); } - /// constuctor that imports from different Point4 types + template + inline void FromEigenVector( const EigenVector & b ) + { + _v[0] = T(b[0]); + _v[1] = T(b[1]); + _v[2] = T(b[2]); + _v[3] = T(b[3]); + } + /// constructor that imports from different Point4 types template static inline Point4 Construct( const Point4 & b ) {