Eigen2Support/Geometry/Rotation2D.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 //
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 // no include guard, we'll include this twice from All.h from Eigen2Support, and it's internal anyway
11 
12 namespace Eigen {
13 
30 template<typename _Scalar> struct ei_traits<Rotation2D<_Scalar> >
31 {
32  typedef _Scalar Scalar;
33 };
34 
35 template<typename _Scalar>
36 class Rotation2D : public RotationBase<Rotation2D<_Scalar>,2>
37 {
39 
40 public:
41 
42  using Base::operator*;
43 
44  enum { Dim = 2 };
46  typedef _Scalar Scalar;
49 
50 protected:
51 
52  Scalar m_angle;
53 
54 public:
55 
57  inline Rotation2D(Scalar a) : m_angle(a) {}
58 
60  inline Scalar angle() const { return m_angle; }
61 
63  inline Scalar& angle() { return m_angle; }
64 
66  inline Rotation2D inverse() const { return -m_angle; }
67 
69  inline Rotation2D operator*(const Rotation2D& other) const
70  { return m_angle + other.m_angle; }
71 
73  inline Rotation2D& operator*=(const Rotation2D& other)
74  { return m_angle += other.m_angle; return *this; }
75 
77  Vector2 operator* (const Vector2& vec) const
78  { return toRotationMatrix() * vec; }
79 
80  template<typename Derived>
81  Rotation2D& fromRotationMatrix(const MatrixBase<Derived>& m);
82  Matrix2 toRotationMatrix(void) const;
83 
87  inline Rotation2D slerp(Scalar t, const Rotation2D& other) const
88  { return m_angle * (1-t) + other.angle() * t; }
89 
95  template<typename NewScalarType>
97  { return typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); }
98 
100  template<typename OtherScalarType>
101  inline explicit Rotation2D(const Rotation2D<OtherScalarType>& other)
102  {
103  m_angle = Scalar(other.angle());
104  }
105 
110  bool isApprox(const Rotation2D& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
111  { return ei_isApprox(m_angle,other.m_angle, prec); }
112 };
113 
120 
125 template<typename Scalar>
126 template<typename Derived>
128 {
129  EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
130  m_angle = ei_atan2(mat.coeff(1,0), mat.coeff(0,0));
131  return *this;
132 }
133 
136 template<typename Scalar>
139 {
140  Scalar sinA = ei_sin(m_angle);
141  Scalar cosA = ei_cos(m_angle);
142  return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
143 }
144 
145 } // end namespace Eigen
internal::cast_return_type< Rotation2D, Rotation2D< NewScalarType > >::type cast() const
static Matrix< Scalar, 2, 2 > toRotationMatrix(const Scalar &s)
Rotation2D & fromRotationMatrix(const MatrixBase< Derived > &m)
Definition: LDLT.h:16
RotationBase< Rotation2D< _Scalar >, 2 > Base
Rotation2D(const Rotation2D< OtherScalarType > &other)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
const internal::permut_matrix_product_retval< PermutationDerived, Derived, OnTheRight > operator*(const MatrixBase< Derived > &matrix, const PermutationBase< PermutationDerived > &permutation)
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
Definition: StaticAssert.h:111
Common base class for compact rotation representations.
T ei_cos(const T &x)
Rotation2D operator*(const Rotation2D &other) const
T ei_sin(const T &x)
Rotation2D & operator*=(const Rotation2D &other)
Represents a rotation/orientation in a 2 dimensional space.
bool ei_isApprox(const Scalar &x, const Scalar &y, typename NumTraits< Scalar >::Real precision=NumTraits< Scalar >::dummy_precision())
T ei_atan2(const T &x, const T &y)
Rotation2D< float > Rotation2Df
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
bool isApprox(const Rotation2D &other, typename NumTraits< Scalar >::Real prec=precision< Scalar >()) const
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Rotation2D slerp(Scalar t, const Rotation2D &other) const
Rotation2D< double > Rotation2Dd


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:56