add transposeInPlace and duplicate V(int)

This commit is contained in:
Paolo Cignoni 2008-10-29 11:17:11 +00:00
parent 07f2e976ea
commit e587581275
12 changed files with 27 additions and 25 deletions

View File

@ -464,7 +464,7 @@ int readmesh(FILE* fp)
}
}
currtrasf = currtrasf.transpose().eval();
currtrasf.transposeInPlace();
// apply tranformation
if(hascolor && savecolor)

View File

@ -641,7 +641,7 @@ public:
int n_rot;
Jacobi(m33,lambda, vect,n_rot);
vect = vect.transpose().eval();
vect.transposeInPlace();
ScalarType normal = std::numeric_limits<ScalarType>::min();
int normI = 0;
for(int i = 0; i < 3; ++i)

View File

@ -728,9 +728,8 @@ namespace vcg{
res.Transpose();
return res;
}
void transposeInPlace() { Transpose(); }
// for the transistion to eigen
const Matrix& eval() { return *this; }
/*!
* Print all matrix elements

View File

@ -403,8 +403,7 @@ public:
res.Transpose();
return res;
}
// for the transistion to eigen
const Matrix33& eval() { return *this; }
void transposeInPlace() { this->Transpose(); }
/// Funzione per costruire una matrice diagonale dati i tre elem.
Matrix33 & SetDiagonal(S *v)

View File

@ -289,8 +289,7 @@ public:
Transpose(res);
return res;
}
// for the transistion to eigen
const Matrix44& eval() { return *this; }
void transposeInPlace() { Transpose(*this); }
void print() {
unsigned int i, j, p;

View File

@ -27,7 +27,7 @@ enum {Dimension = SizeAtCompileTime};
typedef typename ei_to_vcgtype<Matrix>::type EquivVcgType;
typedef vcg::VoidType ParamType;
typedef Matrix PointType;
using Base::V;
// using Base::V;
// automatic conversion to similar vcg types
// the otherway round is implicit because they inherits this Matrix tyoe
@ -78,6 +78,9 @@ inline Scalar& W() { return data()[SizeAtCompileTime-1]; }
/** note, W always returns the last entry */
inline const Scalar& W() const { return data()[SizeAtCompileTime-1]; }
EIGEN_DEPRECATED inline Scalar V(int i) const { return (*this)[i]; };
EIGEN_DEPRECATED inline Scalar& V(int i) { return (*this)[i]; };
/** \deprecated use .data() */
EIGEN_DEPRECATED Scalar* V() { return data(); }
/** \deprecated use .data() */

View File

@ -186,15 +186,20 @@ EIGEN_DEPRECATED void Dump()
printf("\n");
}
// norm2 will be renamed squaredNorm() in Eigen
inline Scalar squaredNorm() const { return norm2(); };
/** \deprecated use norm() */
EIGEN_DEPRECATED inline Scalar Norm() const { return norm(); };
/** \deprecated use squaredNorm() */
EIGEN_DEPRECATED inline Scalar SquaredNorm() const { return norm2(); };
EIGEN_DEPRECATED inline Scalar SquaredNorm() const { return squaredNorm(); };
/** \deprecated use normalize() or normalized() */
EIGEN_DEPRECATED inline Derived& Normalize() { normalize(); return derived(); };
/** \deprecated use normalized() */
EIGEN_DEPRECATED inline const EvalType Normalize() const { return normalized(); };
inline void transposeInPlace() { derived() = derived().transpose().eval(); }
/** \deprecated use .cross(p) */
EIGEN_DEPRECATED inline EvalType operator ^ (const Derived& p ) const { return this->cross(p); }

View File

@ -105,8 +105,8 @@ public:
{ return _ori!=p._ori || _dir!=p._dir; }
/// Projects a point on the line
inline ScalarType Projection( const PointType &p ) const
{ if (NORM) return ScalarType((p-_ori)*_dir);
else return ScalarType((p-_ori)*_dir/_dir.SquaredNorm());
{ if (NORM) return ScalarType((p-_ori).dot(_dir));
else return ScalarType((p-_ori).dot(_dir)/_dir.SquaredNorm());
}
/// returns wheter this type is normalized or not
static bool IsNormalized() {return NORM;};

View File

@ -74,22 +74,22 @@ inline void glMultMatrixE(const Matrix44f &matrix) {
//glMultMatrixf((const GLfloat *)(matrix[0]));
if(glMultTransposeMatrixf) glMultTransposeMatrixf((const GLfloat *)(matrix.V()));
else {
glMultMatrixf((const GLfloat *)(matrix.transpose().eval().V()));
glMultMatrixf((const GLfloat *)(matrix.transpose().V()));
}
}
inline void glMultMatrix(const Matrix44f &matrix) {
glMultMatrixf((const GLfloat *)(matrix.transpose().eval().V()));
glMultMatrixf((const GLfloat *)(matrix.transpose().V()));
}
inline void glMultMatrixE(const Matrix44d &matrix) {
if(glMultTransposeMatrixd) glMultTransposeMatrixd((const GLdouble *)(matrix.V()));
else {
glMultMatrixd((const GLdouble *)(matrix.transpose().eval().V()));
glMultMatrixd((const GLdouble *)(matrix.transpose().V()));
}
}
inline void glMultMatrix(const Matrix44d &matrix) {
glMultMatrixd((const GLdouble *)(matrix.transpose().eval().V()));
glMultMatrixd((const GLdouble *)(matrix.transpose().V()));
}
inline void glMultMatrixDirect(const Matrix44f &matrix) {

View File

@ -84,6 +84,7 @@ y is upward!
#include <vcg/space/plane3.h>
#include <vcg/space/line3.h>
#include <vcg/math/matrix44.h>
#include <wrap/gl/math.h>
#ifdef WIN32
#include <windows.h>
@ -149,12 +150,8 @@ template <class T> void View<T>::GetView() {
// Use standard routines, and transpose manually.
// some 10^-20 seconds slower, but a lot safer
glGetDoublev(GL_PROJECTION_MATRIX, m);
proj.Import(Matrix44d(m));
proj = proj.transpose().eval();
glGetDoublev(GL_MODELVIEW_MATRIX, m);
model.Import(Matrix44d(m));
model = model.transpose().eval();
glGetv(GL_PROJECTION_MATRIX,proj);
glGetv(GL_MODELVIEW_MATRIX,model);
glGetIntegerv(GL_VIEWPORT, (GLint*)viewport);

View File

@ -230,7 +230,7 @@ namespace io {
else return false;
// PTX transformation matrix is transposed
currtrasf = currtrasf.transpose().eval();
currtrasf.transposeInPlace();
// allocating vertex space
int vn = rownum*colnum;