OSVR-Core
RotationBase.h
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 
14 // this file aims to contains the various representations of rotation/orientation
15 // in 2D and 3D space excepted Matrix and Quaternion.
16 
24 template<typename Derived, int _Dim>
25 class RotationBase
26 {
27  public:
28  enum { Dim = _Dim };
31 
34 
35  inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
36  inline Derived& derived() { return *static_cast<Derived*>(this); }
37 
39  inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }
40 
42  inline Derived inverse() const { return derived().inverse(); }
43 
46  { return toRotationMatrix() * t; }
47 
49  inline RotationMatrixType operator*(const Scaling<Scalar,Dim>& s) const
50  { return toRotationMatrix() * s; }
51 
54  { return toRotationMatrix() * t; }
55 };
56 
61 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
62 template<typename OtherDerived>
65 {
66  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
67  *this = r.toRotationMatrix();
68 }
69 
74 template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
75 template<typename OtherDerived>
79 {
80  EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
81  return *this = r.toRotationMatrix();
82 }
83 
102 template<typename Scalar, int Dim>
103 static inline Matrix<Scalar,2,2> ei_toRotationMatrix(const Scalar& s)
104 {
105  EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
107 }
108 
109 template<typename Scalar, int Dim, typename OtherDerived>
110 static inline Matrix<Scalar,Dim,Dim> ei_toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
111 {
112  return r.toRotationMatrix();
113 }
114 
115 template<typename Scalar, int Dim, typename OtherDerived>
116 static inline const MatrixBase<OtherDerived>& ei_toRotationMatrix(const MatrixBase<OtherDerived>& mat)
117 {
118  EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
119  YOU_MADE_A_PROGRAMMING_MISTAKE)
120  return mat;
121 }
122 
123 } // end namespace Eigen
Definition: Scaling.h:29
Matrix< Scalar, Dim, Dim > RotationMatrixType
corresponding linear transformation matrix type
Definition: RotationBase.h:33
Definition: Meta.h:16
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Transform< Scalar, Dim > operator*(const Translation< Scalar, Dim > &t) const
Definition: RotationBase.h:45
RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:39
Transform< Scalar, Dim > operator*(const Transform< Scalar, Dim > &t) const
Definition: RotationBase.h:53
Definition: ForwardDeclarations.h:236
ei_traits< Derived >::Scalar Scalar
the scalar type of the coefficients
Definition: RotationBase.h:30
EIGEN_STRONG_INLINE Matrix()
Default constructor.
Definition: Matrix.h:203
Common base class for compact rotation representations.
Definition: ForwardDeclarations.h:231
RotationMatrixType operator*(const Scaling< Scalar, Dim > &s) const
Definition: RotationBase.h:49
Definition: ForwardDeclarations.h:234
EIGEN_STRONG_INLINE Matrix & operator=(const Matrix &other)
Assigns matrices to each other.
Definition: Matrix.h:154
Derived inverse() const
Definition: RotationBase.h:42
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: Transform.h:43