Deprecating the use of old dangerous linear algebra code. Please use Eigen!

Now attempting to include lin_algebra will block your compilation...
This commit is contained in:
Paolo Cignoni 2012-10-11 10:48:55 +00:00
parent 6750b5d80a
commit 19675a4e33
6 changed files with 56 additions and 20 deletions

View File

@ -50,7 +50,6 @@ added diagonal matrix, outer produce and namespace
#include <assert.h>
#include <algorithm>
#include <vcg/space/point.h>
#include <vcg/math/lin_algebra.h>
namespace vcg{
namespace ndim{
@ -764,22 +763,22 @@ namespace vcg{
/*! @} */
template <class MatrixType>
void Invert(MatrixType & m){
typedef typename MatrixType::ScalarType X;
X *diag;
diag = new X [m.ColumnsNumber()];
// template <class MatrixType>
// void Invert(MatrixType & m){
// typedef typename MatrixType::ScalarType X;
// X *diag;
// diag = new X [m.ColumnsNumber()];
MatrixType res(m.RowsNumber(),m.ColumnsNumber());
vcg::SingularValueDecomposition<MatrixType > (m,&diag[0],res,LeaveUnsorted,50 );
m.Transpose();
// prodotto per la diagonale
unsigned int i,j;
for (i=0; i<m.RowsNumber(); i++)
for (j=0; j<m.ColumnsNumber(); j++)
res[i][j]/= diag[j];
m = res *m;
}
// MatrixType res(m.RowsNumber(),m.ColumnsNumber());
// vcg::SingularValueDecomposition<MatrixType > (m,&diag[0],res,LeaveUnsorted,50 );
// m.Transpose();
// // prodotto per la diagonale
// unsigned int i,j;
// for (i=0; i<m.RowsNumber(); i++)
// for (j=0; j<m.ColumnsNumber(); j++)
// res[i][j]/= diag[j];
// m = res *m;
// }
}
}; // end of namespace

View File

@ -93,7 +93,6 @@ created
#define __VCGLIB_MATRIX33_H
#include <stdio.h>
#include <vcg/math/lin_algebra.h>
#include <vcg/math/matrix44.h>
#include <vcg/space/point3.h>
#include <vector>
@ -151,6 +150,20 @@ public:
}
}
template <class EigenMatrix33Type>
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 <class EigenMatrix33Type>
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
{

View File

@ -247,6 +247,14 @@ public:
template <class Matrix44Type>
void FromMatrix(const Matrix44Type & m){for(int i = 0; i < 16; i++) V()[i]=m.V()[i];}
template <class EigenMatrix44Type>
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();

View File

@ -52,7 +52,9 @@ Added initial disclaimer
#include <vcg/math/base.h>
#include <vcg/math/matrix44.h>
#include <algorithm>
#ifndef _YES_I_WANT_TO_USE_DANGEROUS_STUFF
#error "Please do not never user this file. Use EIGEN!!!!"
#endif
namespace vcg
{
/** \addtogroup math */

View File

@ -172,7 +172,13 @@ public:
_v[1] = P3ScalarType(b[1]);
_v[2] = P3ScalarType(b[2]);
}
template <class EigenVector>
inline void FromEigenVector( const EigenVector & b )
{
_v[0] = P3ScalarType(b[0]);
_v[1] = P3ScalarType(b[1]);
_v[2] = P3ScalarType(b[2]);
}
template <class Q>
static inline Point3 Construct( const Point3<Q> & b )
{

View File

@ -113,7 +113,15 @@ public:
_v[2] = T(b[2]);
_v[3] = T(b[3]);
}
/// constuctor that imports from different Point4 types
template <class EigenVector>
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 <class Q>
static inline Point4 Construct( const Point4<Q> & b )
{