11 #ifndef EIGEN_PARAMETRIZEDLINE_H 12 #define EIGEN_PARAMETRIZEDLINE_H 15 #include "./InternalHeaderCheck.h" 32 template <
typename Scalar_,
int AmbientDim_,
int Options_>
33 class ParametrizedLine {
35 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar_, AmbientDim_)
36 enum { AmbientDimAtCompileTime = AmbientDim_, Options = Options_ };
37 typedef Scalar_ Scalar;
38 typedef typename NumTraits<Scalar>::Real RealScalar;
45 template <
int OtherOptions>
47 : m_origin(other.origin()), m_direction(other.direction()) {}
57 : m_origin(origin), m_direction(direction) {}
59 template <
int OtherOptions>
70 EIGEN_DEVICE_FUNC
inline Index dim()
const {
return m_direction.size(); }
72 EIGEN_DEVICE_FUNC
const VectorType& origin()
const {
return m_origin; }
73 EIGEN_DEVICE_FUNC VectorType& origin() {
return m_origin; }
75 EIGEN_DEVICE_FUNC
const VectorType& direction()
const {
return m_direction; }
76 EIGEN_DEVICE_FUNC VectorType& direction() {
return m_direction; }
83 return (diff - direction().dot(diff) * direction()).squaredNorm();
94 return origin() + direction().dot(p - origin()) * direction();
97 EIGEN_DEVICE_FUNC VectorType
pointAt(
const Scalar& t)
const;
99 template <
int OtherOptions>
100 EIGEN_DEVICE_FUNC Scalar
103 template <
int OtherOptions>
106 template <
int OtherOptions>
107 EIGEN_DEVICE_FUNC VectorType
116 template <
typename XprType>
120 direction() = (mat * direction()).normalized();
122 direction() = mat * direction();
124 eigen_assert(0 &&
"invalid traits value in ParametrizedLine::transform()");
126 origin() = mat * origin();
137 template <
int TrOptions>
150 template <
typename NewScalarType>
151 EIGEN_DEVICE_FUNC
inline 155 return typename internal::cast_return_type<
160 template <
typename OtherScalarType,
int OtherOptions>
163 m_origin = other.origin().template cast<Scalar>();
164 m_direction = other.direction().template cast<Scalar>();
173 return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec);
177 VectorType m_origin, m_direction;
184 template <
typename Scalar_,
int AmbientDim_,
int Options_>
185 template <
int OtherOptions>
188 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(
VectorType, 2)
189 direction() = hyperplane.
normal().unitOrthogonal();
195 template <
typename Scalar_,
int AmbientDim_,
int Options_>
198 return origin() + (direction() * t);
203 template <
typename Scalar_,
int AmbientDim_,
int Options_>
204 template <
int OtherOptions>
207 return -(hyperplane.
offset() + hyperplane.
normal().dot(origin())) / 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
RealScalar distance(const VectorType &p) const
Definition: ParametrizedLine.h:88
ParametrizedLine(const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: ParametrizedLine.h:161
VectorType projection(const VectorType &p) const
Definition: ParametrizedLine.h:93
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
ConstNormalReturnType normal() const
Definition: Hyperplane.h:147
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
Definition: Constants.h:455
Eigen::Index Index
Definition: ParametrizedLine.h:39
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition: ParametrizedLine.h:154
ParametrizedLine()
Definition: ParametrizedLine.h:43
static ParametrizedLine Through(const VectorType &p0, const VectorType &p1)
Definition: ParametrizedLine.h:63
const Scalar & offset() const
Definition: Hyperplane.h:159
VectorType intersectionPoint(const Hyperplane< Scalar_, AmbientDim_, OtherOptions > &hyperplane) const
Definition: ParametrizedLine.h:225
Index dim() const
Definition: ParametrizedLine.h:70
ParametrizedLine(const VectorType &origin, const VectorType &direction)
Definition: ParametrizedLine.h:56
ParametrizedLine & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition: ParametrizedLine.h:117
A hyperplane.
Definition: ForwardDeclarations.h:473
TransformTraits
Definition: Constants.h:453
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
VectorType pointAt(const Scalar &t) const
Definition: ParametrizedLine.h:197
bool isApprox(const ParametrizedLine &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: ParametrizedLine.h:171
RealScalar squaredDistance(const VectorType &p) const
Definition: ParametrizedLine.h:81
ParametrizedLine & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition: ParametrizedLine.h:138
Definition: Constants.h:458
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
A parametrized line.
Definition: ForwardDeclarations.h:471
ParametrizedLine(Index _dim)
Definition: ParametrizedLine.h:51