12#ifndef EIGEN_PARAMETRIZEDLINE_H
13#define EIGEN_PARAMETRIZEDLINE_H
16#include "./InternalHeaderCheck.h"
35template <
typename Scalar_,
int AmbientDim_,
int Options_>
38 EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar_, AmbientDim_)
39 enum { AmbientDimAtCompileTime = AmbientDim_, Options = Options_ };
40 using Scalar = Scalar_;
41 using RealScalar =
typename NumTraits<Scalar>::Real;
48 template <
int OtherOptions>
50 : m_origin(other.origin()), m_direction(other.direction()) {}
60 EIGEN_DEVICE_FUNC
ParametrizedLine(
const VectorType& origin,
const VectorType& direction)
61 : m_origin(origin), m_direction(direction) {}
63 template <
int OtherOptions>
72 EIGEN_DEVICE_FUNC
inline Index dim()
const {
return m_direction.size(); }
74 EIGEN_DEVICE_FUNC
const VectorType& origin()
const {
return m_origin; }
75 EIGEN_DEVICE_FUNC VectorType& origin() {
return m_origin; }
77 EIGEN_DEVICE_FUNC
const VectorType& direction()
const {
return m_direction; }
78 EIGEN_DEVICE_FUNC VectorType& direction() {
return m_direction; }
84 VectorType diff = p - origin();
85 return (diff - direction().dot(diff) * direction()).squaredNorm();
90 EIGEN_DEVICE_FUNC RealScalar
distance(
const VectorType& p)
const {
95 EIGEN_DEVICE_FUNC VectorType
projection(
const VectorType& p)
const {
96 return origin() + direction().dot(p - origin()) * direction();
99 EIGEN_DEVICE_FUNC VectorType
pointAt(
const Scalar& t)
const;
101 template <
int OtherOptions>
102 EIGEN_DEVICE_FUNC Scalar
105 template <
int OtherOptions>
108 template <
int OtherOptions>
109 EIGEN_DEVICE_FUNC VectorType
118 template <
typename XprType>
122 direction() = (mat * direction()).normalized();
124 direction() = mat * direction();
126 eigen_assert(0 &&
"invalid traits value in ParametrizedLine::transform()");
128 origin() = mat * origin();
139 template <
int TrOptions>
152 template <
typename NewScalarType>
153 EIGEN_DEVICE_FUNC
inline
157 return typename internal::cast_return_type<
162 template <
typename OtherScalarType,
int OtherOptions>
166 m_direction = other.direction().template
cast<Scalar>();
177 NumTraits<Scalar>::dummy_precision())
const {
178 return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec);
182 VectorType m_origin, m_direction;
189template <
typename Scalar_,
int AmbientDim_,
int Options_>
190template <
int OtherOptions>
193 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
194 direction() = hyperplane.
normal().unitOrthogonal();
200template <
typename Scalar_,
int AmbientDim_,
int Options_>
201EIGEN_DEVICE_FUNC
inline typename ParametrizedLine<Scalar_, AmbientDim_, Options_>::VectorType
203 return origin() + direction() * t;
208template <
typename Scalar_,
int AmbientDim_,
int Options_>
209template <
int OtherOptions>
210EIGEN_DEVICE_FUNC
inline Scalar_ ParametrizedLine<Scalar_, AmbientDim_, Options_>::intersectionParameter(
212 return -(hyperplane.
offset() + hyperplane.
normal().dot(origin())) / hyperplane.
normal().dot(direction());
218template <
typename Scalar_,
int AmbientDim_,
int Options_>
219template <
int OtherOptions>
220EIGEN_DEVICE_FUNC
inline Scalar_ ParametrizedLine<Scalar_, AmbientDim_, Options_>::intersection(
222 return intersectionParameter(hyperplane);
227template <
typename Scalar_,
int AmbientDim_,
int Options_>
228template <
int OtherOptions>
229EIGEN_DEVICE_FUNC
inline typename ParametrizedLine<Scalar_, AmbientDim_, Options_>::VectorType
232 return pointAt(intersectionParameter(hyperplane));
A hyperplane.
Definition Hyperplane.h:38
ConstNormalReturnType normal() const
Definition Hyperplane.h:146
const Scalar & offset() const
Definition Hyperplane.h:158
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:53
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:188
A parametrized line.
Definition ParametrizedLine.h:36
Eigen::Index Index
Definition ParametrizedLine.h:42
ParametrizedLine & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition ParametrizedLine.h:140
ParametrizedLine & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition ParametrizedLine.h:119
RealScalar squaredDistance(const VectorType &p) const
Definition ParametrizedLine.h:83
RealScalar distance(const VectorType &p) const
Definition ParametrizedLine.h:90
VectorType intersectionPoint(const Hyperplane< Scalar_, AmbientDim_, OtherOptions > &hyperplane) const
Definition ParametrizedLine.h:230
internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition ParametrizedLine.h:156
ParametrizedLine(const VectorType &origin, const VectorType &direction)
Definition ParametrizedLine.h:60
ParametrizedLine(Index _dim)
Definition ParametrizedLine.h:54
bool isApprox(const ParametrizedLine &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition ParametrizedLine.h:176
VectorType pointAt(const Scalar &t) const
Definition ParametrizedLine.h:202
ParametrizedLine()
Definition ParametrizedLine.h:46
static ParametrizedLine Through(const VectorType &p0, const VectorType &p1)
Definition ParametrizedLine.h:67
Index dim() const
Definition ParametrizedLine.h:72
ParametrizedLine(const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition ParametrizedLine.h:163
VectorType projection(const VectorType &p) const
Definition ParametrizedLine.h:95
TransformTraits
Definition Constants.h:470
@ Affine
Definition Constants.h:475
@ Isometry
Definition Constants.h:472