mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-10-17 18:41:31 +08:00
Support matrix multiplication of homogeneous row vectors
This commit is contained in:
parent
2d170aea11
commit
4df215785b
@ -1264,6 +1264,14 @@ struct generic_product_impl<Lhs, Rhs, SkewSymmetricShape, SkewSymmetricShape, Pr
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>
|
||||
struct generic_product_impl<Lhs, Rhs, MatrixShape, HomogeneousShape, ProductTag>
|
||||
: generic_product_impl<Lhs, typename Rhs::PlainObject, MatrixShape, DenseShape, ProductTag> {};
|
||||
|
||||
template <typename Lhs, typename Rhs, int ProductTag, typename MatrixShape>
|
||||
struct generic_product_impl<Lhs, Rhs, HomogeneousShape, MatrixShape, ProductTag>
|
||||
: generic_product_impl<typename Lhs::PlainObject, Rhs, DenseShape, MatrixShape, ProductTag> {};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
} // end namespace Eigen
|
||||
|
@ -80,14 +80,12 @@ class Homogeneous : public MatrixBase<Homogeneous<MatrixType, Direction_> >, int
|
||||
|
||||
template <typename Rhs>
|
||||
EIGEN_DEVICE_FUNC inline const Product<Homogeneous, Rhs> operator*(const MatrixBase<Rhs>& rhs) const {
|
||||
eigen_assert(int(Direction) == Horizontal);
|
||||
return Product<Homogeneous, Rhs>(*this, rhs.derived());
|
||||
}
|
||||
|
||||
template <typename Lhs>
|
||||
friend EIGEN_DEVICE_FUNC inline const Product<Lhs, Homogeneous> operator*(const MatrixBase<Lhs>& lhs,
|
||||
const Homogeneous& rhs) {
|
||||
eigen_assert(int(Direction) == Vertical);
|
||||
return Product<Lhs, Homogeneous>(lhs.derived(), rhs);
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,18 @@ void homogeneous(void) {
|
||||
|
||||
VERIFY_IS_APPROX((t2.template triangularView<Lower>() * v0.homogeneous()).eval(),
|
||||
(t2.template triangularView<Lower>() * hv0));
|
||||
|
||||
{
|
||||
const MatrixType points = MatrixType::Random();
|
||||
const VectorType center = VectorType::Random();
|
||||
|
||||
const auto pts3 = points.rowwise() - center.transpose();
|
||||
const auto pts_xy1 = pts3.template leftCols<Size - 1>().rowwise().homogeneous();
|
||||
const auto pts_xy2 = pts3.template topRows<Size - 1>().colwise().homogeneous();
|
||||
|
||||
VERIFY_IS_APPROX(pts_xy1.transpose() * pts_xy1, pts_xy1.transpose() * pts_xy1.eval());
|
||||
VERIFY_IS_APPROX(pts_xy2 * pts_xy2.transpose(), pts_xy2.eval() * pts_xy2.transpose());
|
||||
}
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(geo_homogeneous) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user