Medial Code Documentation
Loading...
Searching...
No Matches
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 <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_ROTATIONBASE_H
11#define EIGEN_ROTATIONBASE_H
12
13namespace Eigen {
14
15// forward declaration
16namespace internal {
17template<typename RotationDerived, typename MatrixType, bool IsVector=MatrixType::IsVectorAtCompileTime>
19}
20
28template<typename Derived, int _Dim>
30{
31 public:
32 enum { Dim = _Dim };
35
39
40 public:
41 inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
42 inline Derived& derived() { return *static_cast<Derived*>(this); }
43
45 inline RotationMatrixType toRotationMatrix() const { return derived().toRotationMatrix(); }
46
50 inline RotationMatrixType matrix() const { return derived().toRotationMatrix(); }
51
53 inline Derived inverse() const { return derived().inverse(); }
54
58
61 { return toRotationMatrix() * s.factor(); }
62
69 template<typename OtherDerived>
73
75 template<typename OtherDerived> friend
76 inline RotationMatrixType operator*(const EigenBase<OtherDerived>& l, const Derived& r)
77 { return l.derived() * r.toRotationMatrix(); }
78
80 friend inline Transform<Scalar,Dim,Affine> operator*(const DiagonalMatrix<Scalar,Dim>& l, const Derived& r)
81 {
83 res.linear().applyOnTheLeft(l);
84 return res;
85 }
86
88 template<int Mode, int Options>
91
92 template<typename OtherVectorType>
93 inline VectorType _transformVector(const OtherVectorType& v) const
94 { return toRotationMatrix() * v; }
95};
96
97namespace internal {
98
99// implementation of the generic product rotation * matrix
100template<typename RotationDerived, typename MatrixType>
102{
103 enum { Dim = RotationDerived::Dim };
105 static inline ReturnType run(const RotationDerived& r, const MatrixType& m)
106 { return r.toRotationMatrix() * m; }
107};
108
109template<typename RotationDerived, typename Scalar, int Dim, int MaxDim>
111{
113 static inline ReturnType run(const RotationDerived& r, const DiagonalMatrix<Scalar,Dim,MaxDim>& m)
114 {
115 ReturnType res(r);
116 res.linear() *= m;
117 return res;
118 }
119};
120
121template<typename RotationDerived,typename OtherVectorType>
123{
124 enum { Dim = RotationDerived::Dim };
126 static EIGEN_STRONG_INLINE ReturnType run(const RotationDerived& r, const OtherVectorType& v)
127 {
128 return r._transformVector(v);
129 }
130};
131
132} // end namespace internal
133
138template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
139template<typename OtherDerived>
142{
143 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
144 *this = r.toRotationMatrix();
145}
146
151template<typename _Scalar, int _Rows, int _Cols, int _Storage, int _MaxRows, int _MaxCols>
152template<typename OtherDerived>
156{
157 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,int(OtherDerived::Dim),int(OtherDerived::Dim))
158 return *this = r.toRotationMatrix();
159}
160
161namespace internal {
162
181template<typename Scalar, int Dim>
182static inline Matrix<Scalar,2,2> toRotationMatrix(const Scalar& s)
183{
184 EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
185 return Rotation2D<Scalar>(s).toRotationMatrix();
186}
187
188template<typename Scalar, int Dim, typename OtherDerived>
189static inline Matrix<Scalar,Dim,Dim> toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
190{
191 return r.toRotationMatrix();
192}
193
194template<typename Scalar, int Dim, typename OtherDerived>
195static inline const MatrixBase<OtherDerived>& toRotationMatrix(const MatrixBase<OtherDerived>& mat)
196{
197 EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
198 YOU_MADE_A_PROGRAMMING_MISTAKE)
199 return mat;
200}
201
202} // end namespace internal
203
204} // end namespace Eigen
205
206#endif // EIGEN_ROTATIONBASE_H
Represents a diagonal matrix with its storage.
Definition DiagonalMatrix.h:119
Common base class for compact rotation representations.
Definition RotationBase.h:30
RotationMatrixType operator*(const UniformScaling< Scalar > &s) const
Definition RotationBase.h:60
Transform< Scalar, Dim, Isometry > operator*(const Translation< Scalar, Dim > &t) const
Definition RotationBase.h:56
friend RotationMatrixType operator*(const EigenBase< OtherDerived > &l, const Derived &r)
Definition RotationBase.h:76
EIGEN_STRONG_INLINE internal::rotation_base_generic_product_selector< Derived, OtherDerived, OtherDerived::IsVectorAtCompileTime >::ReturnType operator*(const EigenBase< OtherDerived > &e) const
Definition RotationBase.h:71
friend Transform< Scalar, Dim, Affine > operator*(const DiagonalMatrix< Scalar, Dim > &l, const Derived &r)
Definition RotationBase.h:80
Matrix< Scalar, Dim, Dim > RotationMatrixType
corresponding linear transformation matrix type
Definition RotationBase.h:37
Derived inverse() const
Definition RotationBase.h:53
RotationMatrixType matrix() const
Definition RotationBase.h:50
RotationMatrixType toRotationMatrix() const
Definition RotationBase.h:45
Transform< Scalar, Dim, Mode > operator*(const Transform< Scalar, Dim, Mode, Options > &t) const
Definition RotationBase.h:89
internal::traits< Derived >::Scalar Scalar
the scalar type of the coefficients
Definition RotationBase.h:34
Pseudo expression representing a solving operation.
Definition Solve.h:63
Definition ForwardDeclarations.h:17
Definition inference.c:32