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 // apply tranformation
if(hascolor && savecolor) if(hascolor && savecolor)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -186,15 +186,20 @@ EIGEN_DEPRECATED void Dump()
printf("\n"); printf("\n");
} }
// norm2 will be renamed squaredNorm() in Eigen
inline Scalar squaredNorm() const { return norm2(); };
/** \deprecated use norm() */ /** \deprecated use norm() */
EIGEN_DEPRECATED inline Scalar Norm() const { return norm(); }; EIGEN_DEPRECATED inline Scalar Norm() const { return norm(); };
/** \deprecated use squaredNorm() */ /** \deprecated use squaredNorm() */
EIGEN_DEPRECATED inline Scalar SquaredNorm() const { return norm2(); }; EIGEN_DEPRECATED inline Scalar SquaredNorm() const { return squaredNorm(); };
/** \deprecated use normalize() or normalized() */ /** \deprecated use normalize() or normalized() */
EIGEN_DEPRECATED inline Derived& Normalize() { normalize(); return derived(); }; EIGEN_DEPRECATED inline Derived& Normalize() { normalize(); return derived(); };
/** \deprecated use normalized() */ /** \deprecated use normalized() */
EIGEN_DEPRECATED inline const EvalType Normalize() const { return normalized(); }; EIGEN_DEPRECATED inline const EvalType Normalize() const { return normalized(); };
inline void transposeInPlace() { derived() = derived().transpose().eval(); }
/** \deprecated use .cross(p) */ /** \deprecated use .cross(p) */
EIGEN_DEPRECATED inline EvalType operator ^ (const Derived& p ) const { return this->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; } { return _ori!=p._ori || _dir!=p._dir; }
/// Projects a point on the line /// Projects a point on the line
inline ScalarType Projection( const PointType &p ) const inline ScalarType Projection( const PointType &p ) const
{ if (NORM) return ScalarType((p-_ori)*_dir); { if (NORM) return ScalarType((p-_ori).dot(_dir));
else return ScalarType((p-_ori)*_dir/_dir.SquaredNorm()); else return ScalarType((p-_ori).dot(_dir)/_dir.SquaredNorm());
} }
/// returns wheter this type is normalized or not /// returns wheter this type is normalized or not
static bool IsNormalized() {return NORM;}; static bool IsNormalized() {return NORM;};

View File

@ -32,7 +32,7 @@
#include <vcg/math/base.h> #include <vcg/math/base.h>
#include <vcg/space/space.h> #include <vcg/space/space.h>
namespace vcg{ namespace vcg {
template<typename Scalar> class Point2; template<typename Scalar> class Point2;
template<typename Scalar> class Point3; template<typename Scalar> class Point3;
template<typename Scalar> class Point4; template<typename Scalar> class Point4;

View File

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

View File

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

View File

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