Add examples for hnormalized and homogenous (fix bug #846)

This commit is contained in:
Gael Guennebaud 2014-09-02 10:47:40 +02:00
parent eb39296028
commit 305aa1f9c5
5 changed files with 28 additions and 2 deletions

View File

@ -120,7 +120,7 @@ template<typename MatrixType,int _Direction> class Homogeneous
* Example: \include MatrixBase_homogeneous.cpp * Example: \include MatrixBase_homogeneous.cpp
* Output: \verbinclude MatrixBase_homogeneous.out * Output: \verbinclude MatrixBase_homogeneous.out
* *
* \sa class Homogeneous * \sa VectorwiseOp::homogeneous(), class Homogeneous
*/ */
template<typename Derived> template<typename Derived>
inline typename MatrixBase<Derived>::HomogeneousReturnType inline typename MatrixBase<Derived>::HomogeneousReturnType
@ -137,7 +137,7 @@ MatrixBase<Derived>::homogeneous() const
* Example: \include VectorwiseOp_homogeneous.cpp * Example: \include VectorwiseOp_homogeneous.cpp
* Output: \verbinclude VectorwiseOp_homogeneous.out * Output: \verbinclude VectorwiseOp_homogeneous.out
* *
* \sa MatrixBase::homogeneous() */ * \sa MatrixBase::homogeneous(), class Homogeneous */
template<typename ExpressionType, int Direction> template<typename ExpressionType, int Direction>
inline Homogeneous<ExpressionType,Direction> inline Homogeneous<ExpressionType,Direction>
VectorwiseOp<ExpressionType,Direction>::homogeneous() const VectorwiseOp<ExpressionType,Direction>::homogeneous() const

View File

@ -0,0 +1,7 @@
typedef Matrix<double,4,Dynamic> Matrix4Xd;
Matrix4Xd M = Matrix4Xd::Random(4,5);
Projective3d P(Matrix4d::Random());
cout << "The matrix M is:" << endl << M << endl << endl;
cout << "M.colwise().hnormalized():" << endl << M.colwise().hnormalized() << endl << endl;
cout << "P*M:" << endl << P*M << endl << endl;
cout << "(P*M).colwise().hnormalized():" << endl << (P*M).colwise().hnormalized() << endl << endl;

View File

@ -0,0 +1,6 @@
Vector4d v = Vector4d::Random();
Projective3d P(Matrix4d::Random());
cout << "v = " << v.transpose() << "]^T" << endl;
cout << "v.hnormalized() = " << v.hnormalized().transpose() << "]^T" << endl;
cout << "P*v = " << (P*v).transpose() << "]^T" << endl;
cout << "(P*v).hnormalized() = " << (P*v).hnormalized().transpose() << "]^T" << endl;

View File

@ -0,0 +1,6 @@
Vector3d v = Vector3d::Random(), w;
Projective3d P(Matrix4d::Random());
cout << "v = [" << v.transpose() << "]^T" << endl;
cout << "h.homogeneous() = [" << v.homogeneous().transpose() << "]^T" << endl;
cout << "(P * v.homogeneous()) = [" << (P * v.homogeneous()).transpose() << "]^T" << endl;
cout << "(P * v.homogeneous()).hnormalized() = [" << (P * v.homogeneous()).eval().hnormalized().transpose() << "]^T" << endl;

View File

@ -0,0 +1,7 @@
typedef Matrix<double,3,Dynamic> Matrix3Xd;
Matrix3Xd M = Matrix3Xd::Random(3,5);
Projective3d P(Matrix4d::Random());
cout << "The matrix M is:" << endl << M << endl << endl;
cout << "M.colwise().homogeneous():" << endl << M.colwise().homogeneous() << endl << endl;
cout << "P * M.colwise().homogeneous():" << endl << P * M.colwise().homogeneous() << endl << endl;
cout << "P * M.colwise().homogeneous().hnormalized(): " << endl << (P * M.colwise().homogeneous()).colwise().hnormalized() << endl << endl;