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 <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_ROTATION2D_H
11 #define EIGEN_ROTATION2D_H
12 
13 namespace Eigen {
14 
32 namespace internal {
33 
34 template<typename _Scalar> struct traits<Rotation2D<_Scalar> >
35 {
36  typedef _Scalar Scalar;
37 };
38 } // end namespace internal
39 
40 template<typename _Scalar>
41 class Rotation2D : public RotationBase<Rotation2D<_Scalar>,2>
42 {
44 
45 public:
46 
47  using Base::operator*;
48 
49  enum { Dim = 2 };
51  typedef _Scalar Scalar;
54 
55 protected:
56 
57  Scalar m_angle;
58 
59 public:
60 
62  inline Rotation2D(const Scalar& a) : m_angle(a) {}
63 
65  inline Scalar angle() const { return m_angle; }
66 
68  inline Scalar& angle() { return m_angle; }
69 
71  inline Rotation2D inverse() const { return -m_angle; }
72 
74  inline Rotation2D operator*(const Rotation2D& other) const
75  { return m_angle + other.m_angle; }
76 
78  inline Rotation2D& operator*=(const Rotation2D& other)
79  { m_angle += other.m_angle; return *this; }
80 
82  Vector2 operator* (const Vector2& vec) const
83  { return toRotationMatrix() * vec; }
84 
85  template<typename Derived>
86  Rotation2D& fromRotationMatrix(const MatrixBase<Derived>& m);
87  Matrix2 toRotationMatrix(void) const;
88 
92  inline Rotation2D slerp(const Scalar& t, const Rotation2D& other) const
93  { return m_angle * (1-t) + other.angle() * t; }
94 
100  template<typename NewScalarType>
102  { return typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); }
103 
105  template<typename OtherScalarType>
106  inline explicit Rotation2D(const Rotation2D<OtherScalarType>& other)
107  {
108  m_angle = Scalar(other.angle());
109  }
110 
111  static inline Rotation2D Identity() { return Rotation2D(0); }
112 
117  bool isApprox(const Rotation2D& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const
118  { return internal::isApprox(m_angle,other.m_angle, prec); }
119 };
120 
127 
132 template<typename Scalar>
133 template<typename Derived>
135 {
136  using std::atan2;
137  EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
138  m_angle = atan2(mat.coeff(1,0), mat.coeff(0,0));
139  return *this;
140 }
141 
144 template<typename Scalar>
147 {
148  using std::sin;
149  using std::cos;
150  Scalar sinA = sin(m_angle);
151  Scalar cosA = cos(m_angle);
152  return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
153 }
154 
155 } // end namespace Eigen
156 
157 #endif // EIGEN_ROTATION2D_H
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)
Rotation2D slerp(const Scalar &t, const Rotation2D &other) const
Definition: LDLT.h:16
RotationBase< Rotation2D< _Scalar >, 2 > Base
Rotation2D(const Scalar &a)
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
static Rotation2D Identity()
bool isApprox(const Rotation2D &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
bool isApprox(const Scalar &x, const Scalar &y, typename NumTraits< Scalar >::Real precision=NumTraits< Scalar >::dummy_precision())
Common base class for compact rotation representations.
Rotation2D operator*(const Rotation2D &other) const
const CwiseUnaryOp< internal::scalar_sin_op< Scalar >, const Derived > sin() const
Rotation2D inverse() const
Matrix< Scalar, 2, 2 > Matrix2
Rotation2D & operator*=(const Rotation2D &other)
Represents a rotation/orientation in a 2 dimensional space.
#define Rotation2D
Definition: All.h:25
const CwiseUnaryOp< internal::scalar_cos_op< Scalar >, const Derived > cos() const
Matrix< Scalar, 2, 1 > Vector2
Rotation2D< float > Rotation2Df
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Scalar angle() const
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Rotation2D< double > Rotation2Dd


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