some cleaning
This commit is contained in:
parent
2dc124d060
commit
977ddb9623
|
@ -24,46 +24,14 @@
|
||||||
#warning You are including deprecated math stuff
|
#warning You are including deprecated math stuff
|
||||||
/*!
|
/*!
|
||||||
* \deprecated use cols()
|
* \deprecated use cols()
|
||||||
* Number of columns
|
|
||||||
*/
|
*/
|
||||||
EIGEN_DEPRECATED inline unsigned int ColumnsNumber() const
|
EIGEN_DEPRECATED inline unsigned int ColumnsNumber() const { return cols(); };
|
||||||
{
|
|
||||||
return cols();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \deprecated use rows()
|
* \deprecated use rows()
|
||||||
* Number of rows
|
|
||||||
*/
|
*/
|
||||||
EIGEN_DEPRECATED inline unsigned int RowsNumber() const
|
EIGEN_DEPRECATED inline unsigned int RowsNumber() const { return rows(); };
|
||||||
{
|
|
||||||
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);
|
|
||||||
// };
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \deprecated use *this(i,j) (or *this.coeff(i,j))
|
* \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
|
* \param j the column index
|
||||||
* \return the element
|
* \return the element
|
||||||
*/
|
*/
|
||||||
EIGEN_DEPRECATED inline Scalar ElementAt(unsigned int i, unsigned int j) const
|
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); }
|
||||||
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)
|
* \deprecated use *this.determinant() (or *this.lu().determinant() for large matrices)
|
||||||
* Calculate and return the matrix determinant (Laplace)
|
* Calculate and return the matrix determinant (Laplace)
|
||||||
* \return the matrix determinant
|
* \return the matrix determinant
|
||||||
*/
|
*/
|
||||||
EIGEN_DEPRECATED Scalar Determinant() const
|
EIGEN_DEPRECATED Scalar Determinant() const { return determinant(); };
|
||||||
{
|
|
||||||
return determinant();
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Return the cofactor <I>A<SUB>i,j</SUB></I> of the <I>a<SUB>i,j</SUB></I> element
|
* 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();
|
return (((i+j)%2==0) ? 1. : -1.) * minor(i,j).determinant();
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use *this.col(j) */
|
||||||
* \deprecated use *this.col(j)
|
EIGEN_DEPRECATED ColXpr GetColumn(const unsigned int j) { return 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.row(i) */
|
||||||
* \deprecated use *this.row(i)
|
EIGEN_DEPRECATED RowXpr GetRow(const unsigned int i) { return 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 m1.col(i).swap(m1.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 column.
|
|
||||||
* \param i the index of the first column
|
|
||||||
* \param j the index of the second column
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED void SwapColumns(const unsigned int i, const unsigned int j)
|
EIGEN_DEPRECATED void SwapColumns(const unsigned int i, const unsigned int j)
|
||||||
{
|
{
|
||||||
if (i==j)
|
if (i==j) return;
|
||||||
return;
|
|
||||||
|
|
||||||
col(i).swap(col(j));
|
col(i).swap(col(j));
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use m1.col(i).swap(m1.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
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED void SwapRows(const unsigned int i, const unsigned int j)
|
EIGEN_DEPRECATED void SwapRows(const unsigned int i, const unsigned int j)
|
||||||
{
|
{
|
||||||
if (i==j)
|
if (i==j) return;
|
||||||
return;
|
|
||||||
|
|
||||||
row(i).swap(row(j));
|
row(i).swap(row(j));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -198,94 +126,44 @@ EIGEN_DEPRECATED Derived& operator-=(const Scalar k)
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use *this = a * b.transpose() (or *this = a * b.adjoint() for complexes) */
|
||||||
* \deprecated use *this = a * b.transpose()
|
|
||||||
* Matrix from outer product.
|
|
||||||
*/
|
|
||||||
template <typename OtherDerived1, typename OtherDerived2>
|
template <typename OtherDerived1, typename OtherDerived2>
|
||||||
EIGEN_DEPRECATED void OuterProduct(const MatrixBase<OtherDerived1>& a, const MatrixBase<OtherDerived2>& b)
|
EIGEN_DEPRECATED void OuterProduct(const MatrixBase<OtherDerived1>& a, const MatrixBase<OtherDerived2>& b)
|
||||||
{
|
{ *this = a * b.adjoint(); }
|
||||||
*this = a * b.transpose();
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef CwiseUnaryOp<ei_scalar_add_op<Scalar>, Derived> ScalarAddReturnType;
|
typedef CwiseUnaryOp<ei_scalar_add_op<Scalar>, Derived> ScalarAddReturnType;
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use *this.cwise() + k */
|
||||||
* \deprecated use *this.cwise() + k
|
|
||||||
* Scalar sum.
|
|
||||||
* \param k
|
|
||||||
* \return the resultant matrix
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED const ScalarAddReturnType operator+(const Scalar k) { return cwise() + k; }
|
EIGEN_DEPRECATED const ScalarAddReturnType operator+(const Scalar k) { return cwise() + k; }
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use *this.cwise() - k */
|
||||||
* \deprecated use *this.cwise() - k
|
|
||||||
* Scalar difference.
|
|
||||||
* \param k
|
|
||||||
* \return the resultant matrix
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED const ScalarAddReturnType operator-(const Scalar k) { return 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.setIdentity() or *this = MatrixType::Identity(rows,cols), etc. */
|
||||||
* \deprecated use *this.setZero() or *this = MatrixType::Zero(rows,cols), etc.
|
EIGEN_DEPRECATED void SetIdentity() { setIdentity(); };
|
||||||
* Set all the matrix elements to zero.
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED void SetZero()
|
|
||||||
{
|
|
||||||
setZero();
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use *this.col(j) = expression */
|
||||||
* \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 ...
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED void SetColumn(unsigned int j, Scalar* v)
|
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 */
|
/** \deprecated use *this.col(i) = other */
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEPRECATED void SetColumn(unsigned int j, const MatrixBase<OtherDerived>& other)
|
EIGEN_DEPRECATED void SetColumn(unsigned int j, const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{ col(j) = other; };
|
||||||
col(j) = other;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use *this.row(i) = expression */
|
||||||
* \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 ...
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED void SetRow(unsigned int i, Scalar* v)
|
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 */
|
/** \deprecated use *this.row(i) = other */
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EIGEN_DEPRECATED void SetRow(unsigned int j, const MatrixBase<OtherDerived>& other)
|
EIGEN_DEPRECATED void SetRow(unsigned int j, const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{ row(j) = other; };
|
||||||
row(j) = other;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use *this.diagonal() = expression */
|
||||||
* \deprecated use *this.diagonal() = expression
|
|
||||||
* Set the diagonal elements <I>v<SUB>i,i</SUB></I> to v[i]
|
|
||||||
* \param v
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED void SetDiagonal(Scalar *v)
|
EIGEN_DEPRECATED void SetDiagonal(Scalar *v)
|
||||||
{
|
{
|
||||||
assert(rows() == cols());
|
assert(rows() == cols());
|
||||||
|
@ -295,20 +173,7 @@ EIGEN_DEPRECATED void SetDiagonal(Scalar *v)
|
||||||
/** \deprecated use trace() */
|
/** \deprecated use trace() */
|
||||||
EIGEN_DEPRECATED Scalar Trace() const { return trace(); }
|
EIGEN_DEPRECATED Scalar Trace() const { return trace(); }
|
||||||
|
|
||||||
/*!
|
/*! \deprecated use ostream << *this or even ostream << *this.withFormat(...) */
|
||||||
* \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
|
|
||||||
*/
|
|
||||||
EIGEN_DEPRECATED void Dump()
|
EIGEN_DEPRECATED void Dump()
|
||||||
{
|
{
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
|
|
|
@ -99,9 +99,6 @@ public:
|
||||||
|
|
||||||
VCG_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Matrix44)
|
VCG_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Matrix44)
|
||||||
|
|
||||||
/** \name Constructors
|
|
||||||
* No automatic casting and default constructor is empty
|
|
||||||
*/
|
|
||||||
Matrix44() : Base() {}
|
Matrix44() : Base() {}
|
||||||
~Matrix44() {}
|
~Matrix44() {}
|
||||||
Matrix44(const Matrix44 &m) : Base(m) {}
|
Matrix44(const Matrix44 &m) : Base(m) {}
|
||||||
|
@ -113,7 +110,6 @@ public:
|
||||||
const typename Base::RowXpr operator[](int i) const { return Base::row(i); }
|
const typename Base::RowXpr operator[](int i) const { return Base::row(i); }
|
||||||
typename Base::RowXpr operator[](int i) { 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); }
|
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); }
|
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>
|
template <class T>
|
||||||
bool Decompose(Matrix44<T> &M, Point3<T> &ScaleV, Point3<T> &ShearV, Point3<T> &RotV,Point3<T> &TranV)
|
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;
|
return false;
|
||||||
if(math::Abs(M.Determinant())<1e-10) return false; // matrix should be at least invertible...
|
if(math::Abs(M.Determinant())<1e-10) return false; // matrix should be at least invertible...
|
||||||
|
|
||||||
// First Step recover the traslation
|
// First Step recover the traslation
|
||||||
TranV=M.GetColumn3(3);
|
TranV=M.GetColumn3(3);
|
||||||
|
|
||||||
|
|
||||||
// Second Step Recover Scale and Shearing interleaved
|
// Second Step Recover Scale and Shearing interleaved
|
||||||
ScaleV[0]=Norm(M.GetColumn3(0));
|
ScaleV[0]=Norm(M.GetColumn3(0));
|
||||||
Point3<T> R[3];
|
Point3<T> R[3];
|
||||||
|
@ -433,7 +428,7 @@ bool Decompose(Matrix44<T> &M, Point3<T> &ScaleV, Point3<T> &ShearV, Point3<T> &
|
||||||
int i,j;
|
int i,j;
|
||||||
for(i=0;i<3;++i)
|
for(i=0;i<3;++i)
|
||||||
for(j=0;j<3;++j)
|
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
|
// Third and last step: Recover the rotation
|
||||||
//now the matrix should be a pure rotation matrix so its determinant is +-1
|
//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) {
|
if(det<0) {
|
||||||
ScaleV *= -1;
|
ScaleV *= -1;
|
||||||
M *= -1;
|
M *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double alpha,beta,gamma; // rotations around the x,y and z axis
|
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);
|
double cosbeta=cos(beta);
|
||||||
if(math::Abs(cosbeta) > 1e-5)
|
if(math::Abs(cosbeta) > 1e-5)
|
||||||
{
|
{
|
||||||
alpha=asin(-M[1][2]/cosbeta);
|
alpha=asin(-M(1,2)/cosbeta);
|
||||||
if((M[2][2]/cosbeta) < 0 ) alpha=M_PI-alpha;
|
if((M(2,2)/cosbeta) < 0 ) alpha=M_PI-alpha;
|
||||||
gamma=asin(-M[0][1]/cosbeta);
|
gamma=asin(-M(0,1)/cosbeta);
|
||||||
if((M[0][0]/cosbeta)<0) gamma = M_PI-gamma;
|
if((M(0,0)/cosbeta)<0) gamma = M_PI-gamma;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alpha=asin(-M[1][0]);
|
alpha=asin(-M(1,0));
|
||||||
if(M[1][1]<0) alpha=M_PI-alpha;
|
if(M(1,1)<0) alpha=M_PI-alpha;
|
||||||
gamma=0;
|
gamma=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue