11#ifndef EIGEN_PARAMETRIZEDLINE_H
12#define EIGEN_PARAMETRIZEDLINE_H
29template <
typename _Scalar,
int _AmbientDim,
int _Options>
33 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
35 AmbientDimAtCompileTime = _AmbientDim,
38 typedef _Scalar Scalar;
39 typedef typename NumTraits<Scalar>::Real RealScalar;
46 template<
int OtherOptions>
48 : m_origin(other.origin()), m_direction(other.direction())
58 EIGEN_DEVICE_FUNC
ParametrizedLine(
const VectorType& origin,
const VectorType& direction)
59 : m_origin(origin), m_direction(direction) {}
61 template <
int OtherOptions>
71 EIGEN_DEVICE_FUNC
inline Index dim()
const {
return m_direction.size(); }
73 EIGEN_DEVICE_FUNC
const VectorType& origin()
const {
return m_origin; }
74 EIGEN_DEVICE_FUNC VectorType& origin() {
return m_origin; }
76 EIGEN_DEVICE_FUNC
const VectorType& direction()
const {
return m_direction; }
77 EIGEN_DEVICE_FUNC VectorType& direction() {
return m_direction; }
84 VectorType diff = p - origin();
85 return (diff - direction().dot(diff) * direction()).squaredNorm();
93 EIGEN_DEVICE_FUNC VectorType
projection(
const VectorType& p)
const
94 {
return origin() + direction().dot(p-origin()) * direction(); }
98 template <
int OtherOptions>
101 template <
int OtherOptions>
104 template <
int OtherOptions>
112 template<
typename NewScalarType>
113 EIGEN_DEVICE_FUNC
inline typename internal::cast_return_type<
ParametrizedLine,
121 template<
typename OtherScalarType,
int OtherOptions>
125 m_direction = other.direction().template
cast<Scalar>();
132 EIGEN_DEVICE_FUNC
bool isApprox(
const ParametrizedLine& other,
const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision())
const
133 {
return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
137 VectorType m_origin, m_direction;
144template <
typename _Scalar,
int _AmbientDim,
int _Options>
145template <
int OtherOptions>
148 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
149 direction() = hyperplane.
normal().unitOrthogonal();
155template <
typename _Scalar,
int _AmbientDim,
int _Options>
156EIGEN_DEVICE_FUNC
inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
159 return origin() + (direction()*t);
164template <
typename _Scalar,
int _AmbientDim,
int _Options>
165template <
int OtherOptions>
168 return -(hyperplane.
offset()+hyperplane.
normal().dot(origin()))
169 / hyperplane.
normal().dot(direction());
176template <
typename _Scalar,
int _AmbientDim,
int _Options>
177template <
int OtherOptions>
180 return intersectionParameter(hyperplane);
185template <
typename _Scalar,
int _AmbientDim,
int _Options>
186template <
int OtherOptions>
187EIGEN_DEVICE_FUNC
inline typename ParametrizedLine<_Scalar, _AmbientDim,_Options>::VectorType
190 return pointAt(intersectionParameter(hyperplane));
A hyperplane.
Definition Hyperplane.h:35
ConstNormalReturnType normal() const
Definition Hyperplane.h:157
const Scalar & offset() const
Definition Hyperplane.h:167
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
A parametrized line.
Definition ParametrizedLine.h:31
VectorType intersectionPoint(const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
Definition ParametrizedLine.h:188
RealScalar distance(const VectorType &p) const
Definition ParametrizedLine.h:90
VectorType projection(const VectorType &p) const
Definition ParametrizedLine.h:93
Eigen::Index Index
Definition ParametrizedLine.h:40
ParametrizedLine()
Definition ParametrizedLine.h:44
ParametrizedLine(Index _dim)
Definition ParametrizedLine.h:53
RealScalar squaredDistance(const VectorType &p) const
Definition ParametrizedLine.h:82
Index dim() const
Definition ParametrizedLine.h:71
VectorType pointAt(const Scalar &t) const
Definition ParametrizedLine.h:157
ParametrizedLine(const VectorType &origin, const VectorType &direction)
Definition ParametrizedLine.h:58
static ParametrizedLine Through(const VectorType &p0, const VectorType &p1)
Definition ParametrizedLine.h:65
ParametrizedLine(const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition ParametrizedLine.h:122
bool isApprox(const ParametrizedLine &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition ParametrizedLine.h:132
internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition ParametrizedLine.h:114
Namespace containing all symbols from the Eigen library.
Definition A05_PortingFrom2To3.dox:1
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:65