Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
Eigen::ParametrizedLine< _Scalar, _AmbientDim > Class Template Reference

A parametrized line. More...

#include <ParametrizedLine.h>

+ Collaboration diagram for Eigen::ParametrizedLine< _Scalar, _AmbientDim >:

Public Types

enum  { AmbientDimAtCompileTime = _AmbientDim }
 
enum  { AmbientDimAtCompileTime = _AmbientDim, Options = _Options }
 
typedef _Scalar Scalar
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef Matrix< Scalar, AmbientDimAtCompileTime, 1 > VectorType
 
typedef _Scalar Scalar
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef DenseIndex Index
 
typedef Matrix< Scalar, AmbientDimAtCompileTime, 1, Options > VectorType
 

Public Member Functions

 ParametrizedLine ()
 
 ParametrizedLine (int _dim)
 
 ParametrizedLine (const VectorType &origin, const VectorType &direction)
 
 ParametrizedLine (const Hyperplane< _Scalar, _AmbientDim > &hyperplane)
 
int dim () const
 
const VectorTypeorigin () const
 
VectorTypeorigin ()
 
const VectorTypedirection () const
 
VectorTypedirection ()
 
RealScalar squaredDistance (const VectorType &p) const
 
RealScalar distance (const VectorType &p) const
 
VectorType projection (const VectorType &p) const
 
Scalar intersection (const Hyperplane< _Scalar, _AmbientDim > &hyperplane)
 
template<typename NewScalarType >
internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime > >::type cast () const
 
template<typename OtherScalarType >
 ParametrizedLine (const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime > &other)
 
bool isApprox (const ParametrizedLine &other, typename NumTraits< Scalar >::Real prec=precision< Scalar >()) const
 
 ParametrizedLine ()
 
template<int OtherOptions>
 ParametrizedLine (const ParametrizedLine< Scalar, AmbientDimAtCompileTime, OtherOptions > &other)
 
 ParametrizedLine (Index _dim)
 
 ParametrizedLine (const VectorType &origin, const VectorType &direction)
 
template<int OtherOptions>
 ParametrizedLine (const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane)
 
Index dim () const
 
const VectorTypeorigin () const
 
VectorTypeorigin ()
 
const VectorTypedirection () const
 
VectorTypedirection ()
 
RealScalar squaredDistance (const VectorType &p) const
 
RealScalar distance (const VectorType &p) const
 
VectorType projection (const VectorType &p) const
 
VectorType pointAt (const Scalar &t) const
 
template<int OtherOptions>
Scalar intersectionParameter (const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
 
template<int OtherOptions>
Scalar intersection (const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
 
template<int OtherOptions>
VectorType intersectionPoint (const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
 
template<typename NewScalarType >
internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast () const
 
template<typename OtherScalarType , int OtherOptions>
 ParametrizedLine (const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
 
bool isApprox (const ParametrizedLine &other, typename NumTraits< Scalar >::Real prec=NumTraits< Scalar >::dummy_precision()) const
 
template<int OtherOptions>
_Scalar intersectionParameter (const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
 
template<int OtherOptions>
_Scalar intersection (const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
 

Static Public Member Functions

static ParametrizedLine Through (const VectorType &p0, const VectorType &p1)
 
static ParametrizedLine Through (const VectorType &p0, const VectorType &p1)
 

Protected Attributes

VectorType m_origin
 
VectorType m_direction
 

Detailed Description

template<typename _Scalar, int _AmbientDim>
class Eigen::ParametrizedLine< _Scalar, _AmbientDim >

A parametrized line.

A parametrized line is defined by an origin point $ \mathbf{o} $ and a unit direction vector $ \mathbf{d} $ such that the line corresponds to the set $ l(t) = \mathbf{o} + t \mathbf{d} $, $ l \in \mathbf{R} $.

Parameters
_Scalarthe scalar type, i.e., the type of the coefficients
_AmbientDimthe dimension of the ambient space, can be a compile time value or Dynamic.

A parametrized line is defined by an origin point $ \mathbf{o} $ and a unit direction vector $ \mathbf{d} $ such that the line corresponds to the set $ l(t) = \mathbf{o} + t \mathbf{d} $, $ t \in \mathbf{R} $.

Parameters
_Scalarthe scalar type, i.e., the type of the coefficients
_AmbientDimthe dimension of the ambient space, can be a compile time value or Dynamic.

Definition at line 29 of file ParametrizedLine.h.

Constructor & Destructor Documentation

template<typename _Scalar, int _AmbientDim>
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( )
inline

Default constructor without initialization

Definition at line 39 of file ParametrizedLine.h.

39 {}
template<typename _Scalar, int _AmbientDim>
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( int  _dim)
inlineexplicit

Constructs a dynamic-size line with _dim the dimension of the ambient space

Definition at line 43 of file ParametrizedLine.h.

43 : m_origin(_dim), m_direction(_dim) {}
template<typename _Scalar, int _AmbientDim>
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( const VectorType origin,
const VectorType direction 
)
inline

Initializes a parametrized line of direction direction and origin origin.

Warning
the vector direction is assumed to be normalized.

Definition at line 48 of file ParametrizedLine.h.

49  : m_origin(origin), m_direction(direction) {}
template<typename _Scalar , int _AmbientDim>
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( const Hyperplane< _Scalar, _AmbientDim > &  hyperplane)
inlineexplicit

Constructs a parametrized line from a 2D hyperplane

Warning
the ambient space must have dimension 2 such that the hyperplane actually describes a line

Definition at line 125 of file ParametrizedLine.h.

126 {
127  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
128  direction() = hyperplane.normal().unitOrthogonal();
129  origin() = -hyperplane.normal()*hyperplane.offset();
130 }
template<typename _Scalar, int _AmbientDim>
template<typename OtherScalarType >
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime > &  other)
inlineexplicit

Copy constructor with scalar type conversion

Definition at line 102 of file ParametrizedLine.h.

103  {
104  m_origin = other.origin().template cast<Scalar>();
105  m_direction = other.direction().template cast<Scalar>();
106  }
template<typename _Scalar, int _AmbientDim>
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( )
inline

Default constructor without initialization

Definition at line 44 of file ParametrizedLine.h.

44 {}
template<typename _Scalar, int _AmbientDim>
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( Index  _dim)
inlineexplicit

Constructs a dynamic-size line with _dim the dimension of the ambient space

Definition at line 53 of file ParametrizedLine.h.

53 : m_origin(_dim), m_direction(_dim) {}
template<typename _Scalar, int _AmbientDim>
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( const VectorType origin,
const VectorType direction 
)
inline

Initializes a parametrized line of direction direction and origin origin.

Warning
the vector direction is assumed to be normalized.

Definition at line 58 of file ParametrizedLine.h.

59  : m_origin(origin), m_direction(direction) {}
template<typename _Scalar , int _AmbientDim, int _Options>
template<int OtherOptions>
Eigen::ParametrizedLine< _Scalar, _AmbientDim, _Options >::ParametrizedLine ( const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &  hyperplane)
inlineexplicit

Constructs a parametrized line from a 2D hyperplane

Warning
the ambient space must have dimension 2 such that the hyperplane actually describes a line

Definition at line 146 of file ParametrizedLine.h.

147 {
148  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 2)
149  direction() = hyperplane.normal().unitOrthogonal();
150  origin() = -hyperplane.normal()*hyperplane.offset();
151 }
template<typename _Scalar, int _AmbientDim>
template<typename OtherScalarType , int OtherOptions>
Eigen::ParametrizedLine< _Scalar, _AmbientDim >::ParametrizedLine ( const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &  other)
inlineexplicit

Copy constructor with scalar type conversion

Definition at line 122 of file ParametrizedLine.h.

123  {
124  m_origin = other.origin().template cast<Scalar>();
125  m_direction = other.direction().template cast<Scalar>();
126  }

Member Function Documentation

template<typename _Scalar, int _AmbientDim>
template<typename NewScalarType >
internal::cast_return_type<ParametrizedLine, ParametrizedLine<NewScalarType,AmbientDimAtCompileTime> >::type Eigen::ParametrizedLine< _Scalar, _AmbientDim >::cast ( ) const
inline
Returns
*this with scalar type casted to NewScalarType

Note that if NewScalarType is equal to the current scalar type of *this then this function smartly returns a const reference to *this.

Definition at line 94 of file ParametrizedLine.h.

95  {
96  return typename internal::cast_return_type<ParametrizedLine,
97  ParametrizedLine<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
98  }
template<typename _Scalar, int _AmbientDim>
template<typename NewScalarType >
internal::cast_return_type<ParametrizedLine, ParametrizedLine<NewScalarType,AmbientDimAtCompileTime,Options> >::type Eigen::ParametrizedLine< _Scalar, _AmbientDim >::cast ( ) const
inline
Returns
*this with scalar type casted to NewScalarType

Note that if NewScalarType is equal to the current scalar type of *this then this function smartly returns a const reference to *this.

Definition at line 114 of file ParametrizedLine.h.

115  {
116  return typename internal::cast_return_type<ParametrizedLine,
117  ParametrizedLine<NewScalarType,AmbientDimAtCompileTime,Options> >::type(*this);
118  }
template<typename _Scalar, int _AmbientDim>
int Eigen::ParametrizedLine< _Scalar, _AmbientDim >::dim ( ) const
inline
Returns
the dimension in which the line holds

Definition at line 60 of file ParametrizedLine.h.

60 { return m_direction.size(); }
template<typename _Scalar, int _AmbientDim>
Index Eigen::ParametrizedLine< _Scalar, _AmbientDim >::dim ( ) const
inline
Returns
the dimension in which the line holds

Definition at line 71 of file ParametrizedLine.h.

71 { return m_direction.size(); }
template<typename _Scalar, int _AmbientDim>
RealScalar Eigen::ParametrizedLine< _Scalar, _AmbientDim >::distance ( const VectorType p) const
inline
Returns
the distance of a point p to its projection onto the line *this.
See also
squaredDistance()

Definition at line 79 of file ParametrizedLine.h.

79 { return ei_sqrt(squaredDistance(p)); }
RealScalar squaredDistance(const VectorType &p) const
template<typename _Scalar, int _AmbientDim>
RealScalar Eigen::ParametrizedLine< _Scalar, _AmbientDim >::distance ( const VectorType p) const
inline
Returns
the distance of a point p to its projection onto the line *this.
See also
squaredDistance()

Definition at line 90 of file ParametrizedLine.h.

90 { using std::sqrt; return sqrt(squaredDistance(p)); }
RealScalar squaredDistance(const VectorType &p) const
template<typename _Scalar , int _AmbientDim>
_Scalar Eigen::ParametrizedLine< _Scalar, _AmbientDim >::intersection ( const Hyperplane< _Scalar, _AmbientDim > &  hyperplane)
inline
Returns
the parameter value of the intersection between *this and the given hyperplane

Definition at line 135 of file ParametrizedLine.h.

136 {
137  return -(hyperplane.offset()+origin().eigen2_dot(hyperplane.normal()))
138  /(direction().eigen2_dot(hyperplane.normal()));
139 }
template<typename _Scalar, int _AmbientDim>
template<int OtherOptions>
_Scalar Eigen::ParametrizedLine< _Scalar, _AmbientDim >::intersection ( const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &  hyperplane) const
inline
Deprecated:
use intersectionParameter()
Returns
the parameter value of the intersection between *this and the given hyperplane

Definition at line 178 of file ParametrizedLine.h.

179 {
180  return intersectionParameter(hyperplane);
181 }
template<typename _Scalar, int _AmbientDim>
template<int OtherOptions>
_Scalar Eigen::ParametrizedLine< _Scalar, _AmbientDim >::intersectionParameter ( const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &  hyperplane) const
inline
Returns
the parameter value of the intersection between *this and the given hyperplane

Definition at line 166 of file ParametrizedLine.h.

167 {
168  return -(hyperplane.offset()+hyperplane.normal().dot(origin()))
169  / hyperplane.normal().dot(direction());
170 }
template<typename _Scalar , int _AmbientDim, int _Options>
template<int OtherOptions>
ParametrizedLine< _Scalar, _AmbientDim, _Options >::VectorType Eigen::ParametrizedLine< _Scalar, _AmbientDim, _Options >::intersectionPoint ( const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &  hyperplane) const
inline
Returns
the point of the intersection between *this and the given hyperplane

Definition at line 188 of file ParametrizedLine.h.

189 {
190  return pointAt(intersectionParameter(hyperplane));
191 }
VectorType pointAt(const Scalar &t) const
template<typename _Scalar, int _AmbientDim>
bool Eigen::ParametrizedLine< _Scalar, _AmbientDim >::isApprox ( const ParametrizedLine< _Scalar, _AmbientDim > &  other,
typename NumTraits< Scalar >::Real  prec = precision<Scalar>() 
) const
inline
Returns
true if *this is approximately equal to other, within the precision determined by prec.
See also
MatrixBase::isApprox()

Definition at line 112 of file ParametrizedLine.h.

113  { return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
template<typename _Scalar, int _AmbientDim>
bool Eigen::ParametrizedLine< _Scalar, _AmbientDim >::isApprox ( const ParametrizedLine< _Scalar, _AmbientDim > &  other,
typename NumTraits< Scalar >::Real  prec = NumTraits<Scalar>::dummy_precision() 
) const
inline
Returns
true if *this is approximately equal to other, within the precision determined by prec.
See also
MatrixBase::isApprox()

Definition at line 132 of file ParametrizedLine.h.

133  { return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
template<typename _Scalar , int _AmbientDim, int _Options>
ParametrizedLine< _Scalar, _AmbientDim, _Options >::VectorType Eigen::ParametrizedLine< _Scalar, _AmbientDim, _Options >::pointAt ( const Scalar &  t) const
inline
Returns
the point at t along this line

Definition at line 157 of file ParametrizedLine.h.

158 {
159  return origin() + (direction()*t);
160 }
template<typename _Scalar, int _AmbientDim>
VectorType Eigen::ParametrizedLine< _Scalar, _AmbientDim >::projection ( const VectorType p) const
inline
Returns
the projection of a point p onto the line *this.

Definition at line 82 of file ParametrizedLine.h.

83  { return origin() + (p-origin()).eigen2_dot(direction()) * direction(); }
template<typename _Scalar, int _AmbientDim>
VectorType Eigen::ParametrizedLine< _Scalar, _AmbientDim >::projection ( const VectorType p) const
inline
Returns
the projection of a point p onto the line *this.

Definition at line 93 of file ParametrizedLine.h.

94  { return origin() + direction().dot(p-origin()) * direction(); }
template<typename _Scalar, int _AmbientDim>
RealScalar Eigen::ParametrizedLine< _Scalar, _AmbientDim >::squaredDistance ( const VectorType p) const
inline
Returns
the squared distance of a point p to its projection onto the line *this.
See also
distance()

Definition at line 71 of file ParametrizedLine.h.

72  {
73  VectorType diff = p-origin();
74  return (diff - diff.eigen2_dot(direction())* direction()).squaredNorm();
75  }
template<typename _Scalar, int _AmbientDim>
RealScalar Eigen::ParametrizedLine< _Scalar, _AmbientDim >::squaredDistance ( const VectorType p) const
inline
Returns
the squared distance of a point p to its projection onto the line *this.
See also
distance()

Definition at line 82 of file ParametrizedLine.h.

83  {
84  VectorType diff = p - origin();
85  return (diff - direction().dot(diff) * direction()).squaredNorm();
86  }
template<typename _Scalar, int _AmbientDim>
static ParametrizedLine Eigen::ParametrizedLine< _Scalar, _AmbientDim >::Through ( const VectorType p0,
const VectorType p1 
)
inlinestatic

Constructs a parametrized line going from p0 to p1.

Definition at line 54 of file ParametrizedLine.h.

55  { return ParametrizedLine(p0, (p1-p0).normalized()); }
template<typename _Scalar, int _AmbientDim>
static ParametrizedLine Eigen::ParametrizedLine< _Scalar, _AmbientDim >::Through ( const VectorType p0,
const VectorType p1 
)
inlinestatic

Constructs a parametrized line going from p0 to p1.

Definition at line 65 of file ParametrizedLine.h.

66  { return ParametrizedLine(p0, (p1-p0).normalized()); }

The documentation for this class was generated from the following file: