From c06ae325a4332d52e0c6049b4e7d99ac4887b26a Mon Sep 17 00:00:00 2001 From: Andy Somerville Date: Sat, 10 Dec 2011 11:58:38 +0100 Subject: [PATCH] feature 297: add ParametrizedLine::intersectionPoint() and intersectionParam() -> intersection() is deprecated --- Eigen/src/Geometry/ParametrizedLine.h | 46 +++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Geometry/ParametrizedLine.h b/Eigen/src/Geometry/ParametrizedLine.h index b90f9c088..4e4d52f9b 100644 --- a/Eigen/src/Geometry/ParametrizedLine.h +++ b/Eigen/src/Geometry/ParametrizedLine.h @@ -106,8 +106,21 @@ public: VectorType projection(const VectorType& p) const { return origin() + direction().dot(p-origin()) * direction(); } + /** \returns the point at parameter t along the line */ + VectorType intersectionPoint( Scalar t ) const; + + /** \returns parameter t of the intersection of the line with hyperplane */ + template + Scalar intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const; + + /** \returns parameter t of the intersection of the line with hyperplane. (maintained for API compatablity) */ template Scalar intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const; + + /** \returns the intersection point of the line with hyperplane */ + template + VectorType intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const; + /** \returns \c *this with scalar type casted to \a NewScalarType * @@ -155,14 +168,43 @@ inline ParametrizedLine<_Scalar, _AmbientDim,_Options>::ParametrizedLine(const H origin() = -hyperplane.normal()*hyperplane.offset(); } +/** \returns the point at t along this line + */ +template +inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType +ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint( _Scalar t ) const +{ + return origin() + (direction()*t); +} + +/** \returns the parameter value of the intersection between \c *this and the given hyperplane + */ +template +template +inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const +{ + return -(hyperplane.offset()+hyperplane.normal().dot(origin())) + / hyperplane.normal().dot(direction()); +} + + /** \returns the parameter value of the intersection between \c *this and the given hyperplane */ template template inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const { - return -(hyperplane.offset()+hyperplane.normal().dot(origin())) - / hyperplane.normal().dot(direction()); + return intersectionParameter(hyperplane); +} + +/** \returns the point of the intersection between \c *this and the given hyperplane + */ +template +template +inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType +ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const +{ + return intersectionPoint(intersectionParameter(hyperplane)); } #endif // EIGEN_PARAMETRIZEDLINE_H