11 #ifndef EIGEN_PARAMETRIZEDLINE_H 12 #define EIGEN_PARAMETRIZEDLINE_H 29 template <
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;
46 template<
int OtherOptions>
48 : m_origin(other.origin()), m_direction(other.direction())
53 EIGEN_DEVICE_FUNC
inline explicit ParametrizedLine(Index _dim) : m_origin(_dim), m_direction(_dim) {}
58 EIGEN_DEVICE_FUNC
ParametrizedLine(
const VectorType& origin,
const VectorType& direction)
59 : m_origin(origin), m_direction(direction) {}
61 template <
int OtherOptions>
65 EIGEN_DEVICE_FUNC
static inline ParametrizedLine
Through(
const VectorType& p0,
const VectorType& p1)
68 EIGEN_DEVICE_FUNC ~ParametrizedLine() {}
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(); }
96 EIGEN_DEVICE_FUNC VectorType
pointAt(
const Scalar& t)
const;
98 template <
int OtherOptions>
101 template <
int OtherOptions>
104 template <
int OtherOptions>
113 template<
typename XprType>
117 direction() = (mat * direction()).normalized();
119 direction() = mat * direction();
122 eigen_assert(0 &&
"invalid traits value in ParametrizedLine::transform()");
124 origin() = mat * origin();
135 template<
int TrOptions>
149 template<
typename NewScalarType>
150 EIGEN_DEVICE_FUNC
inline typename internal::cast_return_type<
ParametrizedLine,
158 template<
typename OtherScalarType,
int OtherOptions>
161 m_origin = other.origin().template cast<Scalar>();
162 m_direction = other.direction().template cast<Scalar>();
170 {
return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
174 VectorType m_origin, m_direction;
181 template <
typename _Scalar,
int _AmbientDim,
int _Options>
182 template <
int OtherOptions>
185 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
186 direction() = hyperplane.
normal().unitOrthogonal();
192 template <
typename _Scalar,
int _AmbientDim,
int _Options>
196 return origin() + (direction()*t);
201 template <
typename _Scalar,
int _AmbientDim,
int _Options>
202 template <
int OtherOptions>
205 return -(hyperplane.
offset()+hyperplane.
normal().dot(origin()))
206 / hyperplane.
normal().dot(direction());
213 template <
typename _Scalar,
int _AmbientDim,
int _Options>
214 template <
int OtherOptions>
217 return intersectionParameter(hyperplane);
222 template <
typename _Scalar,
int _AmbientDim,
int _Options>
223 template <
int OtherOptions>
227 return pointAt(intersectionParameter(hyperplane));
232 #endif // EIGEN_PARAMETRIZEDLINE_H
const Scalar & offset() const
Definition: Hyperplane.h:167
VectorType projection(const VectorType &p) const
Definition: ParametrizedLine.h:93
ParametrizedLine & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition: ParametrizedLine.h:136
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
Index dim() const
Definition: ParametrizedLine.h:71
ParametrizedLine & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition: ParametrizedLine.h:114
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Definition: Constants.h:457
ParametrizedLine(const VectorType &origin, const VectorType &direction)
Definition: ParametrizedLine.h:58
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
RealScalar distance(const VectorType &p) const
Definition: ParametrizedLine.h:90
VectorType pointAt(const Scalar &t) const
Definition: ParametrizedLine.h:194
VectorType intersectionPoint(const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
Definition: ParametrizedLine.h:225
ParametrizedLine()
Definition: ParametrizedLine.h:44
A hyperplane.
Definition: Hyperplane.h:34
TransformTraits
Definition: Constants.h:455
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Eigen::Index Index
Definition: ParametrizedLine.h:40
internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition: ParametrizedLine.h:151
ConstNormalReturnType normal() const
Definition: Hyperplane.h:157
bool isApprox(const ParametrizedLine &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: ParametrizedLine.h:169
RealScalar squaredDistance(const VectorType &p) const
Definition: ParametrizedLine.h:82
static ParametrizedLine Through(const VectorType &p0, const VectorType &p1)
Definition: ParametrizedLine.h:65
ParametrizedLine(Index _dim)
Definition: ParametrizedLine.h:53
Definition: Constants.h:460
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
A parametrized line.
Definition: ParametrizedLine.h:30
ParametrizedLine(const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: ParametrizedLine.h:159