snark
math/rotation_matrix.h
1 // This file is part of snark, a generic and flexible library
2 // for robotics research.
3 //
4 // Copyright (C) 2011 The University of Sydney
5 //
6 // snark is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 3 of the License, or (at your option) any later version.
10 //
11 // snark is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14 // for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with snark. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SNARK_GRAPHICS_IMPL_ROTATION_MATRIX_H_
20 #define SNARK_GRAPHICS_IMPL_ROTATION_MATRIX_H_
21 
22 #include <comma/base/exception.h>
23 #include <Eigen/Core>
24 #include <Eigen/Geometry>
25 
26 namespace snark {
27 
29 class rotation_matrix
30 {
31 public:
32  rotation_matrix( const ::Eigen::Matrix3d& rotation = ::Eigen::Matrix3d::Identity() );
33  rotation_matrix( const ::Eigen::Quaterniond& quaternion );
34  rotation_matrix( const ::Eigen::Vector3d& rpy );
35 
36  const ::Eigen::Matrix3d& rotation() const;
37  ::Eigen::Quaterniond quaternion() const;
38  ::Eigen::Vector3d roll_pitch_yaw() const;
39  static ::Eigen::Vector3d roll_pitch_yaw( const ::Eigen::Matrix3d& m );
40  static ::Eigen::Matrix3d rotation( const ::Eigen::Vector3d& rpy );
41  static ::Eigen::Matrix3d rotation( double roll, double pitch, double yaw );
42 
44  template< typename Output >
45  Output convert() const;
46 
47 private:
48  ::Eigen::Matrix3d m_rotation;
49 
50 };
51 
52 } // namespace snark {
53 
54 #endif // SNARK_GRAPHICS_IMPL_ROTATION_MATRIX_H_