mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 12:19:12 +08:00
feature 297: s/intersectionPoint/pointAt, fix documentation, add a unit test
This commit is contained in:
parent
c06ae325a4
commit
2600ba1731
@ -106,22 +106,17 @@ public:
|
|||||||
VectorType projection(const VectorType& p) const
|
VectorType projection(const VectorType& p) const
|
||||||
{ return origin() + direction().dot(p-origin()) * direction(); }
|
{ return origin() + direction().dot(p-origin()) * direction(); }
|
||||||
|
|
||||||
/** \returns the point at parameter t along the line */
|
VectorType pointAt( Scalar t ) const;
|
||||||
VectorType intersectionPoint( Scalar t ) const;
|
|
||||||
|
|
||||||
/** \returns parameter t of the intersection of the line with hyperplane */
|
|
||||||
template <int OtherOptions>
|
template <int OtherOptions>
|
||||||
Scalar intersectionParameter(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
|
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 <int OtherOptions>
|
template <int OtherOptions>
|
||||||
Scalar intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
|
Scalar intersection(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
|
||||||
|
|
||||||
/** \returns the intersection point of the line with hyperplane */
|
|
||||||
template <int OtherOptions>
|
template <int OtherOptions>
|
||||||
VectorType intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
|
VectorType intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const;
|
||||||
|
|
||||||
|
|
||||||
/** \returns \c *this with scalar type casted to \a NewScalarType
|
/** \returns \c *this with scalar type casted to \a NewScalarType
|
||||||
*
|
*
|
||||||
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
|
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
|
||||||
@ -168,16 +163,16 @@ inline ParametrizedLine<_Scalar, _AmbientDim,_Options>::ParametrizedLine(const H
|
|||||||
origin() = -hyperplane.normal()*hyperplane.offset();
|
origin() = -hyperplane.normal()*hyperplane.offset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns the point at t along this line
|
/** \returns the point at \a t along this line
|
||||||
*/
|
*/
|
||||||
template <typename _Scalar, int _AmbientDim, int _Options>
|
template <typename _Scalar, int _AmbientDim, int _Options>
|
||||||
inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
|
inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
|
||||||
ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint( _Scalar t ) const
|
ParametrizedLine<_Scalar, _AmbientDim,_Options>::pointAt( _Scalar t ) const
|
||||||
{
|
{
|
||||||
return origin() + (direction()*t);
|
return origin() + (direction()*t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns the parameter value of the intersection between \c *this and the given hyperplane
|
/** \returns the parameter value of the intersection between \c *this and the given \a hyperplane
|
||||||
*/
|
*/
|
||||||
template <typename _Scalar, int _AmbientDim, int _Options>
|
template <typename _Scalar, int _AmbientDim, int _Options>
|
||||||
template <int OtherOptions>
|
template <int OtherOptions>
|
||||||
@ -188,7 +183,8 @@ inline _Scalar ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPara
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \returns the parameter value of the intersection between \c *this and the given hyperplane
|
/** \deprecated use intersectionParameter()
|
||||||
|
* \returns the parameter value of the intersection between \c *this and the given \a hyperplane
|
||||||
*/
|
*/
|
||||||
template <typename _Scalar, int _AmbientDim, int _Options>
|
template <typename _Scalar, int _AmbientDim, int _Options>
|
||||||
template <int OtherOptions>
|
template <int OtherOptions>
|
||||||
@ -204,7 +200,7 @@ template <int OtherOptions>
|
|||||||
inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
|
inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
|
||||||
ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
|
ParametrizedLine<_Scalar, _AmbientDim,_Options>::intersectionPoint(const Hyperplane<_Scalar, _AmbientDim, OtherOptions>& hyperplane) const
|
||||||
{
|
{
|
||||||
return intersectionPoint(intersectionParameter(hyperplane));
|
return pointAt(intersectionParameter(hyperplane));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // EIGEN_PARAMETRIZEDLINE_H
|
#endif // EIGEN_PARAMETRIZEDLINE_H
|
||||||
|
@ -40,6 +40,7 @@ template<typename LineType> void parametrizedline(const LineType& _line)
|
|||||||
typedef Matrix<Scalar, LineType::AmbientDimAtCompileTime, 1> VectorType;
|
typedef Matrix<Scalar, LineType::AmbientDimAtCompileTime, 1> VectorType;
|
||||||
typedef Matrix<Scalar, LineType::AmbientDimAtCompileTime,
|
typedef Matrix<Scalar, LineType::AmbientDimAtCompileTime,
|
||||||
LineType::AmbientDimAtCompileTime> MatrixType;
|
LineType::AmbientDimAtCompileTime> MatrixType;
|
||||||
|
typedef Hyperplane<Scalar,LineType::AmbientDimAtCompileTime> HyperplaneType;
|
||||||
|
|
||||||
VectorType p0 = VectorType::Random(dim);
|
VectorType p0 = VectorType::Random(dim);
|
||||||
VectorType p1 = VectorType::Random(dim);
|
VectorType p1 = VectorType::Random(dim);
|
||||||
@ -64,6 +65,16 @@ template<typename LineType> void parametrizedline(const LineType& _line)
|
|||||||
VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),l0);
|
VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),l0);
|
||||||
ParametrizedLine<Scalar,Dim> hp1d = l0.template cast<Scalar>();
|
ParametrizedLine<Scalar,Dim> hp1d = l0.template cast<Scalar>();
|
||||||
VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),l0);
|
VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),l0);
|
||||||
|
|
||||||
|
// intersections
|
||||||
|
VectorType p2 = VectorType::Random(dim);
|
||||||
|
VectorType n2 = VectorType::Random(dim).normalized();
|
||||||
|
HyperplaneType hp(p2,n2);
|
||||||
|
Scalar t = l0.intersectionParameter(hp);
|
||||||
|
VectorType pi = l0.pointAt(t);
|
||||||
|
VERIFY_IS_MUCH_SMALLER_THAN(hp.signedDistance(pi), RealScalar(1));
|
||||||
|
VERIFY_IS_MUCH_SMALLER_THAN(l0.distance(pi), RealScalar(1));
|
||||||
|
VERIFY_IS_APPROX(l0.intersectionPoint(hp), pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Scalar> void parametrizedline_alignment()
|
template<typename Scalar> void parametrizedline_alignment()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user