Eigen2Support/Geometry/ParametrizedLine.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
5 // Copyright (C) 2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 // no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
12 
13 namespace Eigen {
14 
28 template <typename _Scalar, int _AmbientDim>
30 {
31 public:
33  enum { AmbientDimAtCompileTime = _AmbientDim };
34  typedef _Scalar Scalar;
37 
39  inline ParametrizedLine() {}
40 
43  inline explicit ParametrizedLine(int _dim) : m_origin(_dim), m_direction(_dim) {}
44 
48  ParametrizedLine(const VectorType& origin, const VectorType& direction)
49  : m_origin(origin), m_direction(direction) {}
50 
51  explicit ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
52 
54  static inline ParametrizedLine Through(const VectorType& p0, const VectorType& p1)
55  { return ParametrizedLine(p0, (p1-p0).normalized()); }
56 
58 
60  inline int dim() const { return m_direction.size(); }
61 
62  const VectorType& origin() const { return m_origin; }
63  VectorType& origin() { return m_origin; }
64 
65  const VectorType& direction() const { return m_direction; }
66  VectorType& direction() { return m_direction; }
67 
71  RealScalar squaredDistance(const VectorType& p) const
72  {
73  VectorType diff = p-origin();
74  return (diff - diff.eigen2_dot(direction())* direction()).squaredNorm();
75  }
79  RealScalar distance(const VectorType& p) const { return ei_sqrt(squaredDistance(p)); }
80 
82  VectorType projection(const VectorType& p) const
83  { return origin() + (p-origin()).eigen2_dot(direction()) * direction(); }
84 
85  Scalar intersection(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
86 
92  template<typename NewScalarType>
95  {
98  }
99 
101  template<typename OtherScalarType>
103  {
104  m_origin = other.origin().template cast<Scalar>();
105  m_direction = other.direction().template cast<Scalar>();
106  }
107 
112  bool isApprox(const ParametrizedLine& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
113  { return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
114 
115 protected:
116 
117  VectorType m_origin, m_direction;
118 };
119 
124 template <typename _Scalar, int _AmbientDim>
126 {
128  direction() = hyperplane.normal().unitOrthogonal();
129  origin() = -hyperplane.normal()*hyperplane.offset();
130 }
131 
134 template <typename _Scalar, int _AmbientDim>
136 {
137  return -(hyperplane.offset()+origin().eigen2_dot(hyperplane.normal()))
138  /(direction().eigen2_dot(hyperplane.normal()));
139 }
140 
141 } // end namespace Eigen
static ParametrizedLine Through(const VectorType &p0, const VectorType &p1)
RealScalar squaredDistance(const VectorType &p) const
const NormalReturnType normal() const
bool isApprox(const ParametrizedLine &other, typename NumTraits< Scalar >::Real prec=precision< Scalar >()) const
Matrix< Scalar, AmbientDimAtCompileTime, 1 > VectorType
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: matrix.hpp:471
internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime > >::type cast() const
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
RealScalar distance(const VectorType &p) const
ParametrizedLine(const VectorType &origin, const VectorType &direction)
VectorType projection(const VectorType &p) const
ParametrizedLine(const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime > &other)
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar, Size)
Scalar intersection(const Hyperplane< _Scalar, _AmbientDim > &hyperplane)
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
Definition: StaticAssert.h:141


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:55