Translation.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 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_TRANSLATION_H
11 #define EIGEN_TRANSLATION_H
12 
13 namespace Eigen {
14 
29 template<typename _Scalar, int _Dim>
30 class Translation
31 {
32 public:
35  enum { Dim = _Dim };
37  typedef _Scalar Scalar;
46 
47 protected:
48 
50 
51 public:
52 
56  EIGEN_DEVICE_FUNC inline Translation(const Scalar& sx, const Scalar& sy)
57  {
58  eigen_assert(Dim==2);
59  m_coeffs.x() = sx;
60  m_coeffs.y() = sy;
61  }
63  EIGEN_DEVICE_FUNC inline Translation(const Scalar& sx, const Scalar& sy, const Scalar& sz)
64  {
65  eigen_assert(Dim==3);
66  m_coeffs.x() = sx;
67  m_coeffs.y() = sy;
68  m_coeffs.z() = sz;
69  }
72 
74  EIGEN_DEVICE_FUNC inline Scalar x() const { return m_coeffs.x(); }
76  EIGEN_DEVICE_FUNC inline Scalar y() const { return m_coeffs.y(); }
78  EIGEN_DEVICE_FUNC inline Scalar z() const { return m_coeffs.z(); }
79 
81  EIGEN_DEVICE_FUNC inline Scalar& x() { return m_coeffs.x(); }
83  EIGEN_DEVICE_FUNC inline Scalar& y() { return m_coeffs.y(); }
85  EIGEN_DEVICE_FUNC inline Scalar& z() { return m_coeffs.z(); }
86 
87  EIGEN_DEVICE_FUNC const VectorType& vector() const { return m_coeffs; }
89 
90  EIGEN_DEVICE_FUNC const VectorType& translation() const { return m_coeffs; }
92 
95  { return Translation(m_coeffs + other.m_coeffs); }
96 
99 
101  template<typename OtherDerived>
103 
105  template<typename Derived>
107  { return *this * IsometryTransformType(r); }
108 
110  // its a nightmare to define a templated friend function outside its declaration
111  template<typename OtherDerived> friend
113  {
115  res.matrix().setZero();
116  res.linear() = linear.derived();
117  res.translation() = linear.derived() * t.m_coeffs;
118  res.matrix().row(Dim).setZero();
119  res(Dim,Dim) = Scalar(1);
120  return res;
121  }
122 
124  template<int Mode, int Options>
126  {
128  res.pretranslate(m_coeffs);
129  return res;
130  }
131 
133  template<typename Derived>
135  operator* (const MatrixBase<Derived>& vec) const
136  { return m_coeffs + vec.derived(); }
137 
139  Translation inverse() const { return Translation(-m_coeffs); }
140 
141  static const Translation Identity() { return Translation(VectorType::Zero()); }
142 
148  template<typename NewScalarType>
151 
153  template<typename OtherScalarType>
155  { m_coeffs = other.vector().template cast<Scalar>(); }
156 
162  { return m_coeffs.isApprox(other.m_coeffs, prec); }
163 
164 };
165 
173 
174 template<typename Scalar, int Dim>
177 {
179  res.matrix().setZero();
180  res.linear().diagonal().fill(other.factor());
181  res.translation() = m_coeffs;
182  res(Dim,Dim) = Scalar(1);
183  return res;
184 }
185 
186 template<typename Scalar, int Dim>
187 template<typename OtherDerived>
190 {
192  res.matrix().setZero();
193  res.linear() = linear.derived();
194  res.translation() = m_coeffs;
195  res.matrix().row(Dim).setZero();
196  res(Dim,Dim) = Scalar(1);
197  return res;
198 }
199 
200 } // end namespace Eigen
201 
202 #endif // EIGEN_TRANSLATION_H
Eigen::Translation2d
Translation< double, 2 > Translation2d
Definition: Translation.h:169
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen::Translation3f
Translation< float, 3 > Translation3f
Definition: Translation.h:170
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::internal::cast_return_type
Definition: XprHelper.h:509
Eigen::Translation::operator*
friend EIGEN_DEVICE_FUNC AffineTransformType operator*(const EigenBase< OtherDerived > &linear, const Translation &t)
Definition: Translation.h:112
Eigen::EigenBase::derived
EIGEN_DEVICE_FUNC Derived & derived()
Definition: EigenBase.h:46
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::Translation::isApprox
EIGEN_DEVICE_FUNC bool isApprox(const Translation &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Translation.h:161
Eigen::Translation::Translation
EIGEN_DEVICE_FUNC Translation()
Definition: Translation.h:54
Eigen::Translation::Dim
@ Dim
Definition: Translation.h:35
Eigen::EigenBase
Definition: EigenBase.h:29
eigen_assert
#define eigen_assert(x)
Definition: Macros.h:1037
Eigen::Translation2f
Translation< float, 2 > Translation2f
Definition: Translation.h:168
type
Definition: pytypes.h:1525
Eigen::Translation::IsometryTransformType
Transform< Scalar, Dim, Isometry > IsometryTransformType
Definition: Translation.h:45
res
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
Eigen::Translation::Scalar
_Scalar Scalar
Definition: Translation.h:37
Eigen::Translation::x
EIGEN_DEVICE_FUNC Scalar & x()
Returns the x-translation as a reference.
Definition: Translation.h:81
Eigen::Translation::Translation
EIGEN_DEVICE_FUNC Translation(const Translation< OtherScalarType, Dim > &other)
Definition: Translation.h:154
Eigen::Translation::translation
const EIGEN_DEVICE_FUNC VectorType & translation() const
Definition: Translation.h:90
Eigen::Translation::VectorType
Matrix< Scalar, Dim, 1 > VectorType
Definition: Translation.h:39
Eigen::RotationBase
Common base class for compact rotation representations.
Definition: ForwardDeclarations.h:286
Eigen::Translation::Translation
EIGEN_DEVICE_FUNC Translation(const Scalar &sx, const Scalar &sy)
Definition: Translation.h:56
Eigen::Translation::vector
EIGEN_DEVICE_FUNC VectorType & vector()
Definition: Translation.h:88
Eigen::Translation::LinearMatrixType
Matrix< Scalar, Dim, Dim > LinearMatrixType
Definition: Translation.h:41
Eigen::Translation::z
EIGEN_DEVICE_FUNC Scalar & z()
Returns the z-translation as a reference.
Definition: Translation.h:85
Eigen::Translation3d
Translation< double, 3 > Translation3d
Definition: Translation.h:171
Eigen::Translation::operator*
EIGEN_DEVICE_FUNC Translation operator*(const Translation &other) const
Definition: Translation.h:94
Eigen::Translation::vector
const EIGEN_DEVICE_FUNC VectorType & vector() const
Definition: Translation.h:87
Eigen::Translation::y
EIGEN_DEVICE_FUNC Scalar & y()
Returns the y-translation as a reference.
Definition: Translation.h:83
Eigen::Translation::translation
EIGEN_DEVICE_FUNC VectorType & translation()
Definition: Translation.h:91
Eigen::Translation::cast
EIGEN_DEVICE_FUNC internal::cast_return_type< Translation, Translation< NewScalarType, Dim > >::type cast() const
Definition: Translation.h:149
Eigen::Translation::AffineTransformType
Transform< Scalar, Dim, Affine > AffineTransformType
Definition: Translation.h:43
Eigen::UniformScaling
Represents a generic uniform scaling transformation.
Definition: ForwardDeclarations.h:297
Eigen::Translation::Translation
EIGEN_DEVICE_FUNC Translation(const Scalar &sx, const Scalar &sy, const Scalar &sz)
Definition: Translation.h:63
Eigen::Translation
Represents a translation transformation.
Definition: ForwardDeclarations.h:291
Eigen::Matrix< Scalar, Dim, 1 >
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Eigen::Translation::Identity
static const Translation Identity()
Definition: Translation.h:141
Eigen::internal::enable_if
Definition: Meta.h:273
align_3::t
Point2 t(10, 10)
Eigen::Translation::Translation
EIGEN_DEVICE_FUNC Translation(const VectorType &vector)
Definition: Translation.h:71
Eigen::Translation::x
EIGEN_DEVICE_FUNC Scalar x() const
Returns the x-translation by value.
Definition: Translation.h:74
Eigen::Translation::inverse
Translation inverse() const
Definition: Translation.h:139
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:232
Eigen::Translation::m_coeffs
VectorType m_coeffs
Definition: Translation.h:49
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
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Translation::y
EIGEN_DEVICE_FUNC Scalar y() const
Returns the y-translation by value.
Definition: Translation.h:76
Eigen::Translation::z
EIGEN_DEVICE_FUNC Scalar z() const
Returns the z-translation by value.
Definition: Translation.h:78
Eigen::Translation::operator*
EIGEN_DEVICE_FUNC IsometryTransformType operator*(const RotationBase< Derived, Dim > &r) const
Definition: Translation.h:106


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:08:05