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 // IWYU pragma: private
15 #include "./InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
32 template <typename Scalar_, int AmbientDim_, int Options_>
34  public:
36  enum { AmbientDimAtCompileTime = AmbientDim_, Options = Options_ };
37  typedef Scalar_ Scalar;
39  typedef Eigen::Index Index;
41 
44 
45  template <int OtherOptions>
47  : m_origin(other.origin()), m_direction(other.direction()) {}
48 
51  EIGEN_DEVICE_FUNC inline explicit ParametrizedLine(Index _dim) : m_origin(_dim), m_direction(_dim) {}
52 
58 
59  template <int OtherOptions>
61 
64  return ParametrizedLine(p0, (p1 - p0).normalized());
65  }
66 
68 
70  EIGEN_DEVICE_FUNC inline Index dim() const { return m_direction.size(); }
71 
72  EIGEN_DEVICE_FUNC const VectorType& origin() const { return m_origin; }
74 
77 
82  VectorType diff = p - origin();
83  return (diff - direction().dot(diff) * direction()).squaredNorm();
84  }
90  }
91 
94  return origin() + direction().dot(p - origin()) * direction();
95  }
96 
98 
99  template <int OtherOptions>
102 
103  template <int OtherOptions>
105 
106  template <int OtherOptions>
109 
116  template <typename XprType>
118  TransformTraits traits = Affine) {
119  if (traits == Affine)
120  direction() = (mat * direction()).normalized();
121  else if (traits == Isometry)
122  direction() = mat * direction();
123  else {
124  eigen_assert(0 && "invalid traits value in ParametrizedLine::transform()");
125  }
126  origin() = mat * origin();
127  return *this;
128  }
129 
137  template <int TrOptions>
140  transform(t.linear(), traits);
141  origin() += t.translation();
142  return *this;
143  }
144 
150  template <typename NewScalarType>
151  EIGEN_DEVICE_FUNC inline
154  cast() const {
155  return typename internal::cast_return_type<
157  }
158 
160  template <typename OtherScalarType, int OtherOptions>
163  m_origin = other.origin().template cast<Scalar>();
164  m_direction = other.direction().template cast<Scalar>();
165  }
166 
171  EIGEN_DEVICE_FUNC bool isApprox(const ParametrizedLine& other, const typename NumTraits<Scalar>::Real& prec =
173  return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec);
174  }
175 
176  protected:
178 };
179 
184 template <typename Scalar_, int AmbientDim_, int Options_>
185 template <int OtherOptions>
189  direction() = hyperplane.normal().unitOrthogonal();
190  origin() = -hyperplane.normal() * hyperplane.offset();
191 }
192 
195 template <typename Scalar_, int AmbientDim_, int Options_>
198  return origin() + (direction() * t);
199 }
200 
203 template <typename Scalar_, int AmbientDim_, int Options_>
204 template <int OtherOptions>
207  return -(hyperplane.offset() + hyperplane.normal().dot(origin())) / hyperplane.normal().dot(direction());
208 }
209 
213 template <typename Scalar_, int AmbientDim_, int Options_>
214 template <int OtherOptions>
217  return intersectionParameter(hyperplane);
218 }
219 
222 template <typename Scalar_, int AmbientDim_, int Options_>
223 template <int OtherOptions>
227  return pointAt(intersectionParameter(hyperplane));
228 }
229 
230 } // end namespace Eigen
231 
232 #endif // EIGEN_PARAMETRIZEDLINE_H
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
#define EIGEN_USING_STD(FUNC)
Definition: Macros.h:1090
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define eigen_assert(x)
Definition: Macros.h:910
Vector3f p0
Definition: MatrixBase_all.cpp:2
Vector3f p1
Definition: MatrixBase_all.cpp:2
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar, Size)
Definition: Memory.h:880
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
Definition: StaticAssert.h:50
float * p
Definition: Tutorial_Map_using.cpp:9
SCALAR Scalar
Definition: bench_gemm.cpp:45
A hyperplane.
Definition: Hyperplane.h:37
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
A parametrized line.
Definition: ParametrizedLine.h:33
EIGEN_DEVICE_FUNC Index dim() const
Definition: ParametrizedLine.h:70
EIGEN_DEVICE_FUNC ParametrizedLine(Index _dim)
Definition: ParametrizedLine.h:51
EIGEN_DEVICE_FUNC Scalar intersectionParameter(const Hyperplane< Scalar_, AmbientDim_, OtherOptions > &hyperplane) const
EIGEN_DEVICE_FUNC VectorType pointAt(const Scalar &t) const
Definition: ParametrizedLine.h:197
Scalar_ Scalar
Definition: ParametrizedLine.h:37
@ AmbientDimAtCompileTime
Definition: ParametrizedLine.h:36
@ Options
Definition: ParametrizedLine.h:36
EIGEN_DEVICE_FUNC ParametrizedLine(const ParametrizedLine< Scalar, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: ParametrizedLine.h:46
VectorType m_origin
Definition: ParametrizedLine.h:177
EIGEN_DEVICE_FUNC VectorType & origin()
Definition: ParametrizedLine.h:73
EIGEN_DEVICE_FUNC RealScalar squaredDistance(const VectorType &p) const
Definition: ParametrizedLine.h:81
EIGEN_DEVICE_FUNC ParametrizedLine()
Definition: ParametrizedLine.h:43
static EIGEN_DEVICE_FUNC ParametrizedLine Through(const VectorType &p0, const VectorType &p1)
Definition: ParametrizedLine.h:63
EIGEN_DEVICE_FUNC internal::cast_return_type< ParametrizedLine, ParametrizedLine< NewScalarType, AmbientDimAtCompileTime, Options > >::type cast() const
Definition: ParametrizedLine.h:154
Matrix< Scalar, AmbientDimAtCompileTime, 1, Options > VectorType
Definition: ParametrizedLine.h:40
EIGEN_DEVICE_FUNC VectorType intersectionPoint(const Hyperplane< Scalar_, AmbientDim_, OtherOptions > &hyperplane) const
Definition: ParametrizedLine.h:225
EIGEN_DEVICE_FUNC const VectorType & direction() const
Definition: ParametrizedLine.h:75
EIGEN_DEVICE_FUNC VectorType & direction()
Definition: ParametrizedLine.h:76
EIGEN_DEVICE_FUNC ParametrizedLine & transform(const Transform< Scalar, AmbientDimAtCompileTime, Affine, TrOptions > &t, TransformTraits traits=Affine)
Definition: ParametrizedLine.h:138
EIGEN_DEVICE_FUNC bool isApprox(const ParametrizedLine &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: ParametrizedLine.h:171
EIGEN_DEVICE_FUNC VectorType projection(const VectorType &p) const
Definition: ParametrizedLine.h:93
EIGEN_DEVICE_FUNC ParametrizedLine(const VectorType &origin, const VectorType &direction)
Definition: ParametrizedLine.h:56
EIGEN_DEVICE_FUNC const VectorType & origin() const
Definition: ParametrizedLine.h:72
EIGEN_DEVICE_FUNC ParametrizedLine(const ParametrizedLine< OtherScalarType, AmbientDimAtCompileTime, OtherOptions > &other)
Definition: ParametrizedLine.h:161
EIGEN_DEVICE_FUNC ~ParametrizedLine()
Definition: ParametrizedLine.h:67
EIGEN_DEVICE_FUNC Scalar intersection(const Hyperplane< Scalar_, AmbientDim_, OtherOptions > &hyperplane) const
NumTraits< Scalar >::Real RealScalar
Definition: ParametrizedLine.h:38
Eigen::Index Index
Definition: ParametrizedLine.h:39
EIGEN_DEVICE_FUNC ParametrizedLine & transform(const MatrixBase< XprType > &mat, TransformTraits traits=Affine)
Definition: ParametrizedLine.h:117
VectorType m_direction
Definition: ParametrizedLine.h:177
EIGEN_DEVICE_FUNC RealScalar distance(const VectorType &p) const
Definition: ParametrizedLine.h:88
Represents an homogeneous transformation in a N dimensional space.
Definition: Transform.h:192
void hyperplane(const HyperplaneType &_plane)
Definition: geo_hyperplane.cpp:17
TransformTraits
Definition: Constants.h:453
@ Affine
Definition: Constants.h:458
@ Isometry
Definition: Constants.h:455
Scalar EIGEN_BLAS_FUNC_NAME() dot(int *n, Scalar *px, int *incx, Scalar *py, int *incy)
Definition: level1_real_impl.h:52
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
type
Definition: compute_granudrum_aor.py:141
t
Definition: plotPSD.py:36
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: XprHelper.h:583
Definition: fft_test_shared.h:66