some cleaning

This commit is contained in:
Paolo Cignoni 2008-10-28 10:16:43 +00:00
parent 2dc124d060
commit 977ddb9623
2 changed files with 88 additions and 228 deletions

View File

@ -24,46 +24,14 @@
#warning You are including deprecated math stuff
/*!
* \deprecated use cols()
* Number of columns
*/
EIGEN_DEPRECATED inline unsigned int ColumnsNumber() const
{
return cols();
};
EIGEN_DEPRECATED inline unsigned int ColumnsNumber() const { return cols(); };
/*!
* \deprecated use rows()
* Number of rows
*/
EIGEN_DEPRECATED inline unsigned int RowsNumber() const
{
return rows();
};
/*
* \deprecated use *this.isApprox(m) or *this.cwise() == m
* Equality operator.
* \param m
* \return true iff the matrices have same size and its elements have same values.
*/
// template<typename OtherDerived>
// EIGEN_DEPRECATED bool operator==(const MatrixBase<OtherDerived> &m) const
// {
// return (this->cwise() == m);
// }
/*
* \deprecated use !*this.isApprox(m) or *this.cwise() != m
* Inequality operator
* \param m
* \return true iff the matrices have different size or if their elements have different values.
*/
// template<typename OtherDerived>
// EIGEN_DEPRECATED bool operator!=(const MatrixBase<OtherDerived> &m) const
// {
// return (this->cwise() != m);
// };
EIGEN_DEPRECATED inline unsigned int RowsNumber() const { return rows(); };
/*!
* \deprecated use *this(i,j) (or *this.coeff(i,j))
@ -72,25 +40,15 @@ EIGEN_DEPRECATED inline unsigned int RowsNumber() const
* \param j the column index
* \return the element
*/
EIGEN_DEPRECATED inline Scalar ElementAt(unsigned int i, unsigned int j) const
{
return (*this)(i,j);
}
EIGEN_DEPRECATED inline Scalar& ElementAt(unsigned int i, unsigned int j)
{
return (*this)(i,j);
}
EIGEN_DEPRECATED inline Scalar ElementAt(unsigned int i, unsigned int j) const { return (*this)(i,j); }
EIGEN_DEPRECATED inline Scalar& ElementAt(unsigned int i, unsigned int j) { return (*this)(i,j); }
/*!
* \deprecated use *this.determinant() (or *this.lu().determinant() for large matrices)
* Calculate and return the matrix determinant (Laplace)
* \return the matrix determinant
*/
EIGEN_DEPRECATED Scalar Determinant() const
{
return determinant();
};
EIGEN_DEPRECATED Scalar Determinant() const { return determinant(); };
/*!
* Return the cofactor <I>A<SUB>i,j</SUB></I> of the <I>a<SUB>i,j</SUB></I> element
@ -103,53 +61,23 @@ EIGEN_DEPRECATED Scalar Cofactor(unsigned int i, unsigned int j) const
return (((i+j)%2==0) ? 1. : -1.) * minor(i,j).determinant();
};
/*!
* \deprecated use *this.col(j)
* Get the <I>j</I>-th column on the matrix.
* \param j the column index.
* \return the reference to the column elements. This pointer must be deallocated by the caller.
*/
EIGEN_DEPRECATED ColXpr GetColumn(const unsigned int j)
{
return col(j);
};
/*! \deprecated use *this.col(j) */
EIGEN_DEPRECATED ColXpr GetColumn(const unsigned int j) { return col(j); };
/*!
* \deprecated use *this.row(i)
* Get the <I>i</I>-th row on the matrix.
* \param i the column index.
* \return the reference to the row elements. This pointer must be deallocated by the caller.
*/
EIGEN_DEPRECATED RowXpr GetRow(const unsigned int i)
{
return row(i);
};
/*! \deprecated use *this.row(i) */
EIGEN_DEPRECATED RowXpr GetRow(const unsigned int i) { return row(i); };
/*!
* \deprecated use m1.col(i).swap(m1.col(j));
* Swaps the values of the elements between the <I>i</I>-th and the <I>j</I>-th column.
* \param i the index of the first column
* \param j the index of the second column
*/
/*! \deprecated use m1.col(i).swap(m1.col(j)); */
EIGEN_DEPRECATED void SwapColumns(const unsigned int i, const unsigned int j)
{
if (i==j)
return;
if (i==j) return;
col(i).swap(col(j));
};
/*!
* \deprecated use m1.col(i).swap(m1.col(j))
* Swaps the values of the elements between the <I>i</I>-th and the <I>j</I>-th row.
* \param i the index of the first row
* \param j the index of the second row
*/
/*! \deprecated use m1.col(i).swap(m1.col(j)) */
EIGEN_DEPRECATED void SwapRows(const unsigned int i, const unsigned int j)
{
if (i==j)
return;
if (i==j) return;
row(i).swap(row(j));
};
@ -198,94 +126,44 @@ EIGEN_DEPRECATED Derived& operator-=(const Scalar k)
// };
/*!
* \deprecated use *this = a * b.transpose()
* Matrix from outer product.
*/
/*! \deprecated use *this = a * b.transpose() (or *this = a * b.adjoint() for complexes) */
template <typename OtherDerived1, typename OtherDerived2>
EIGEN_DEPRECATED void OuterProduct(const MatrixBase<OtherDerived1>& a, const MatrixBase<OtherDerived2>& b)
{
*this = a * b.transpose();
}
{ *this = a * b.adjoint(); }
typedef CwiseUnaryOp<ei_scalar_add_op<Scalar>, Derived> ScalarAddReturnType;
/*!
* \deprecated use *this.cwise() + k
* Scalar sum.
* \param k
* \return the resultant matrix
*/
/*! \deprecated use *this.cwise() + k */
EIGEN_DEPRECATED const ScalarAddReturnType operator+(const Scalar k) { return cwise() + k; }
/*!
* \deprecated use *this.cwise() - k
* Scalar difference.
* \param k
* \return the resultant matrix
*/
/*! \deprecated use *this.cwise() - k */
EIGEN_DEPRECATED const ScalarAddReturnType operator-(const Scalar k) { return cwise() - k; }
/*! \deprecated use *this.setZero() or *this = MatrixType::Zero(rows,cols), etc. */
EIGEN_DEPRECATED void SetZero() { setZero(); };
/*!
* \deprecated use *this.setZero() or *this = MatrixType::Zero(rows,cols), etc.
* Set all the matrix elements to zero.
*/
EIGEN_DEPRECATED void SetZero()
{
setZero();
};
/*! \deprecated use *this.setIdentity() or *this = MatrixType::Identity(rows,cols), etc. */
EIGEN_DEPRECATED void SetIdentity() { setIdentity(); };
/*!
* \deprecated use *this.setIdentity() or *this = MatrixType::Identity(rows,cols), etc.
* Set the matrix to identity.
*/
EIGEN_DEPRECATED void SetIdentity()
{
setIdentity();
};
/*!
* \deprecated use *this.col(j) = expression
* Set the values of <I>j</I>-th column to v[j]
* \param j the column index
* \param v ...
*/
/*! \deprecated use *this.col(j) = expression */
EIGEN_DEPRECATED void SetColumn(unsigned int j, Scalar* v)
{
col(j) = Map<Matrix<Scalar,RowsAtCompileTime,1> >(v,cols(),1);
};
{ col(j) = Map<Matrix<Scalar,RowsAtCompileTime,1> >(v,cols(),1); };
/** \deprecated use *this.col(i) = other */
template<typename OtherDerived>
EIGEN_DEPRECATED void SetColumn(unsigned int j, const MatrixBase<OtherDerived>& other)
{
col(j) = other;
};
{ col(j) = other; };
/*!
* \deprecated use *this.row(i) = expression
* Set the elements of the <I>i</I>-th row to v[j]
* \param i the row index
* \param v ...
*/
/*! \deprecated use *this.row(i) = expression */
EIGEN_DEPRECATED void SetRow(unsigned int i, Scalar* v)
{
row(i) = Map<Matrix<Scalar,1,ColsAtCompileTime> >(v,1,rows());
};
{ row(i) = Map<Matrix<Scalar,1,ColsAtCompileTime> >(v,1,rows()); };
/** \deprecated use *this.row(i) = other */
template<typename OtherDerived>
EIGEN_DEPRECATED void SetRow(unsigned int j, const MatrixBase<OtherDerived>& other)
{
row(j) = other;
};
{ row(j) = other; };
/*!
* \deprecated use *this.diagonal() = expression
* Set the diagonal elements <I>v<SUB>i,i</SUB></I> to v[i]
* \param v
*/
/*! \deprecated use *this.diagonal() = expression */
EIGEN_DEPRECATED void SetDiagonal(Scalar *v)
{
assert(rows() == cols());
@ -295,20 +173,7 @@ EIGEN_DEPRECATED void SetDiagonal(Scalar *v)
/** \deprecated use trace() */
EIGEN_DEPRECATED Scalar Trace() const { return trace(); }
/*!
* \deprecated use *this = *this.transpose()
*/
// Transpose already exist
// EIGEN_DEPRECATED void Transpose()
// {
// assert(0 && "dangerous use of deprecated Transpose function, please use: m = m.transpose();");
// };
/*!
* \deprecated use ostream << *this or ostream << *this.withFormat(...)
* Print all matrix elements
*/
/*! \deprecated use ostream << *this or even ostream << *this.withFormat(...) */
EIGEN_DEPRECATED void Dump()
{
unsigned int i, j;

View File

@ -99,9 +99,6 @@ public:
VCG_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Matrix44)
/** \name Constructors
* No automatic casting and default constructor is empty
*/
Matrix44() : Base() {}
~Matrix44() {}
Matrix44(const Matrix44 &m) : Base(m) {}
@ -113,7 +110,6 @@ public:
const typename Base::RowXpr operator[](int i) const { return Base::row(i); }
typename Base::RowXpr operator[](int i) { return Base::row(i); }
// return a copy of the i-th column
typename Base::ColXpr GetColumn4(const int& i) const { return Base::col(i); }
const Eigen::Block<Base,3,1> GetColumn3(const int& i) const { return this->template block<3,1>(0,i); }
@ -393,14 +389,13 @@ double srv() { return (double(rand()%40)-20)/2.0; } // small random value
template <class T>
bool Decompose(Matrix44<T> &M, Point3<T> &ScaleV, Point3<T> &ShearV, Point3<T> &RotV,Point3<T> &TranV)
{
if(!(M[3][0]==0 && M[3][1]==0 && M[3][2]==0 && M[3][3]==1) ) // the matrix is projective
if(!(M(3,0)==0 && M(3,1)==0 && M(3,2)==0 && M(3,3)==1) ) // the matrix is projective
return false;
if(math::Abs(M.Determinant())<1e-10) return false; // matrix should be at least invertible...
// First Step recover the traslation
TranV=M.GetColumn3(3);
// Second Step Recover Scale and Shearing interleaved
ScaleV[0]=Norm(M.GetColumn3(0));
Point3<T> R[3];
@ -433,7 +428,7 @@ bool Decompose(Matrix44<T> &M, Point3<T> &ScaleV, Point3<T> &ShearV, Point3<T> &
int i,j;
for(i=0;i<3;++i)
for(j=0;j<3;++j)
M[i][j]=R[j][i];
M(i,j)=R[j][i];
// Third and last step: Recover the rotation
//now the matrix should be a pure rotation matrix so its determinant is +-1
@ -443,22 +438,22 @@ bool Decompose(Matrix44<T> &M, Point3<T> &ScaleV, Point3<T> &ShearV, Point3<T> &
if(det<0) {
ScaleV *= -1;
M *= -1;
}
}
double alpha,beta,gamma; // rotations around the x,y and z axis
beta=asin( M[0][2]);
beta=asin( M(0,2));
double cosbeta=cos(beta);
if(math::Abs(cosbeta) > 1e-5)
{
alpha=asin(-M[1][2]/cosbeta);
if((M[2][2]/cosbeta) < 0 ) alpha=M_PI-alpha;
gamma=asin(-M[0][1]/cosbeta);
if((M[0][0]/cosbeta)<0) gamma = M_PI-gamma;
alpha=asin(-M(1,2)/cosbeta);
if((M(2,2)/cosbeta) < 0 ) alpha=M_PI-alpha;
gamma=asin(-M(0,1)/cosbeta);
if((M(0,0)/cosbeta)<0) gamma = M_PI-gamma;
}
else
{
alpha=asin(-M[1][0]);
if(M[1][1]<0) alpha=M_PI-alpha;
alpha=asin(-M(1,0));
if(M(1,1)<0) alpha=M_PI-alpha;
gamma=0;
}