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 <gael.guennebaud@inria.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 #ifndef EIGEN_PARAMETRIZEDLINE_H
12 #define EIGEN_PARAMETRIZEDLINE_H
13 
14 namespace Eigen {
15 
29 template <typename _Scalar, int _AmbientDim, int _Options>
30 class ParametrizedLine
31 {
32 public:
34  enum {
35  AmbientDimAtCompileTime = _AmbientDim,
36  Options = _Options
37  };
38  typedef _Scalar Scalar;
40  typedef Eigen::Index Index;
42 
45 
46  template<int OtherOptions>
49  {}
50 
53  EIGEN_DEVICE_FUNC inline explicit ParametrizedLine(Index _dim) : m_origin(_dim), m_direction(_dim) {}
54 
60 
61  template <int OtherOptions>
63 
66  { return ParametrizedLine(p0, (p1-p0).normalized()); }
67 
69 
71  EIGEN_DEVICE_FUNC inline Index dim() const { return m_direction.size(); }
72 
73  EIGEN_DEVICE_FUNC const VectorType& origin() const { return m_origin; }
75 
78 
83  {
84  VectorType diff = p - origin();
85  return (diff - direction().dot(diff) * direction()).squaredNorm();
86  }
91 
94  { return origin() + direction().dot(p-origin()) * direction(); }
95 
97 
98  template <int OtherOptions>
100 
101  template <int OtherOptions>
103 
104  template <int OtherOptions>
106 
113  template<typename XprType>
115  {
116  if (traits==Affine)
117  direction() = (mat * direction()).normalized();
118  else if (traits==Isometry)
119  direction() = mat * direction();
120  else
121  {
122  eigen_assert(0 && "invalid traits value in ParametrizedLine::transform()");
123  }
124  origin() = mat * origin();
125  return *this;
126  }
127 
135  template<int TrOptions>
137  TransformTraits traits = Affine)
138  {
139  transform(t.linear(), traits);
140  origin() += t.translation();
141  return *this;
142  }
143 
149  template<typename NewScalarType>
152  {
155  }
156 
158  template<typename OtherScalarType,int OtherOptions>
160  {
161  m_origin = other.origin().template cast<Scalar>();
162  m_direction = other.direction().template cast<Scalar>();
163  }
164 
170  { return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); }
171 
172 protected:
173 
175 };
176 
181 template <typename _Scalar, int _AmbientDim, int _Options>
182 template <int OtherOptions>
184 {
186  direction() = hyperplane.normal().unitOrthogonal();
187  origin() = -hyperplane.normal()*hyperplane.offset();
188 }
189 
192 template <typename _Scalar, int _AmbientDim, int _Options>
195 {
196  return origin() + (direction()*t);
197 }
198 
201 template <typename _Scalar, int _AmbientDim, int _Options>
202 template <int OtherOptions>
204 {
205  return -(hyperplane.offset()+hyperplane.normal().dot(origin()))
206  / hyperplane.normal().dot(direction());
207 }
208 
209 
213 template <typename _Scalar, int _AmbientDim, int _Options>
214 template <int OtherOptions>
216 {
217  return intersectionParameter(hyperplane);
218 }
219 
222 template <typename _Scalar, int _AmbientDim, int _Options>
223 template <int OtherOptions>
226 {
227  return pointAt(intersectionParameter(hyperplane));
228 }
229 
230 } // end namespace Eigen
231 
232 #endif // EIGEN_PARAMETRIZEDLINE_H
Eigen::ParametrizedLine::ParametrizedLine
EIGEN_DEVICE_FUNC ParametrizedLine(const ParametrizedLine< Scalar, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: ParametrizedLine.h:47
Eigen::ParametrizedLine::Options
@ Options
Definition: ParametrizedLine.h:36
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::internal::cast_return_type
Definition: XprHelper.h:509
Eigen::ParametrizedLine::projection
EIGEN_DEVICE_FUNC VectorType projection(const VectorType &p) const
Definition: ParametrizedLine.h:93
Eigen::ParametrizedLine::VectorType
Matrix< Scalar, AmbientDimAtCompileTime, 1, Options > VectorType
Definition: ParametrizedLine.h:41
gtsam.examples.DogLegOptimizerExample.type
type
Definition: DogLegOptimizerExample.py:111
Eigen::Transform
Represents an homogeneous transformation in a N dimensional space.
Definition: ForwardDeclarations.h:294
EIGEN_USING_STD
#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1185
Eigen::Affine
@ Affine
Definition: Constants.h:460
Eigen::ParametrizedLine::Through
static EIGEN_DEVICE_FUNC ParametrizedLine Through(const VectorType &p0, const VectorType &p1)
Definition: ParametrizedLine.h:65
eigen_assert
#define eigen_assert(x)
Definition: Macros.h:1037
Eigen::ParametrizedLine::intersectionParameter
EIGEN_DEVICE_FUNC Scalar intersectionParameter(const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
Eigen::ParametrizedLine::direction
const EIGEN_DEVICE_FUNC VectorType & direction() const
Definition: ParametrizedLine.h:76
Eigen::ParametrizedLine::dim
EIGEN_DEVICE_FUNC Index dim() const
Definition: ParametrizedLine.h:71
type
Definition: pytypes.h:1525
Eigen::ParametrizedLine::transform
EIGEN_DEVICE_FUNC ParametrizedLine & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition: ParametrizedLine.h:114
Eigen::ParametrizedLine::ParametrizedLine
EIGEN_DEVICE_FUNC ParametrizedLine()
Definition: ParametrizedLine.h:44
mat
MatrixXf mat
Definition: Tutorial_AdvancedInitialization_CommaTemporary.cpp:1
Eigen::ParametrizedLine::squaredDistance
EIGEN_DEVICE_FUNC RealScalar squaredDistance(const VectorType &p) const
Definition: ParametrizedLine.h:82
Eigen::ParametrizedLine::transform
EIGEN_DEVICE_FUNC ParametrizedLine & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition: ParametrizedLine.h:136
dot
Scalar EIGEN_BLAS_FUNC() dot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
Definition: level1_real_impl.h:49
Eigen::Isometry
@ Isometry
Definition: Constants.h:457
Eigen::TransformTraits
TransformTraits
Definition: Constants.h:455
hyperplane
void hyperplane(const HyperplaneType &_plane)
Definition: geo_hyperplane.cpp:16
Eigen::ParametrizedLine::ParametrizedLine
EIGEN_DEVICE_FUNC ParametrizedLine(Index _dim)
Definition: ParametrizedLine.h:53
Eigen::ParametrizedLine::AmbientDimAtCompileTime
@ AmbientDimAtCompileTime
Definition: ParametrizedLine.h:35
Eigen::Hyperplane
A hyperplane.
Definition: ForwardDeclarations.h:296
Eigen::ParametrizedLine::origin
EIGEN_DEVICE_FUNC VectorType & origin()
Definition: ParametrizedLine.h:74
Eigen::ParametrizedLine::intersectionPoint
EIGEN_DEVICE_FUNC VectorType intersectionPoint(const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
Definition: ParametrizedLine.h:225
Eigen::ParametrizedLine::pointAt
EIGEN_DEVICE_FUNC VectorType pointAt(const Scalar &t) const
Definition: ParametrizedLine.h:194
Eigen::ParametrizedLine
A parametrized line.
Definition: ForwardDeclarations.h:295
p1
Vector3f p1
Definition: MatrixBase_all.cpp:2
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
Definition: StaticAssert.h:157
Eigen::ParametrizedLine::isApprox
EIGEN_DEVICE_FUNC bool isApprox(const ParametrizedLine &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: ParametrizedLine.h:169
p0
Vector3f p0
Definition: MatrixBase_all.cpp:2
origin
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set origin
Definition: gnuplot_common_settings.hh:45
p
float * p
Definition: Tutorial_Map_using.cpp:9
Eigen::ParametrizedLine::~ParametrizedLine
EIGEN_DEVICE_FUNC ~ParametrizedLine()
Definition: ParametrizedLine.h:68
Eigen::ParametrizedLine::intersection
EIGEN_DEVICE_FUNC Scalar intersection(const Hyperplane< _Scalar, _AmbientDim, OtherOptions > &hyperplane) const
Eigen::ParametrizedLine::RealScalar
NumTraits< Scalar >::Real RealScalar
Definition: ParametrizedLine.h:39
Eigen::ParametrizedLine::Scalar
_Scalar Scalar
Definition: ParametrizedLine.h:38
Eigen::ParametrizedLine::Index
Eigen::Index Index
Definition: ParametrizedLine.h:40
Eigen::Matrix< Scalar, AmbientDimAtCompileTime, 1, Options >
Eigen::ParametrizedLine::ParametrizedLine
EIGEN_DEVICE_FUNC ParametrizedLine(const VectorType &origin, const VectorType &direction)
Definition: ParametrizedLine.h:58
Eigen::ParametrizedLine::ParametrizedLine
EIGEN_DEVICE_FUNC ParametrizedLine(const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: ParametrizedLine.h:159
VectorType
Definition: FFTW.cpp:65
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Eigen::ParametrizedLine::cast
EIGEN_DEVICE_FUNC internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition: ParametrizedLine.h:151
Eigen::ParametrizedLine::m_origin
VectorType m_origin
Definition: ParametrizedLine.h:174
align_3::t
Point2 t(10, 10)
Eigen::ParametrizedLine::direction
EIGEN_DEVICE_FUNC VectorType & direction()
Definition: ParametrizedLine.h:77
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:232
Eigen::ParametrizedLine::m_direction
VectorType m_direction
Definition: ParametrizedLine.h:174
ceres::sqrt
Jet< T, N > sqrt(const Jet< T, N > &f)
Definition: jet.h:418
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar, Size)
Definition: Memory.h:842
Eigen::ParametrizedLine::distance
EIGEN_DEVICE_FUNC RealScalar distance(const VectorType &p) const
Definition: ParametrizedLine.h:90
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::ParametrizedLine::origin
const EIGEN_DEVICE_FUNC VectorType & origin() const
Definition: ParametrizedLine.h:73
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:33:54