mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
pose.h
Go to the documentation of this file.
1 #ifndef MF_POSE_H_
2 #define MF_POSE_H_
3 
4 #include "../eigen.h"
5 #include <ostream>
6 #include <string>
7 #include "angle.h"
8 
9 namespace mf {
10 
12 
15 class pose {
16 public:
19  // TODO make private, enforce normalization, change to matrix?
20 
22  pose();
23 
25  pose(const pose&) = default;
26 
28 
30  pose(const Eigen_affine3&);
31 
33  template<typename Translation, typename Rotation>
34  pose(const Translation& t, const Rotation& r) :
35  position(t),
36  orientation(r) { orientation.normalize(); }
37 
40 
43 
46  }
47 
50  }
51 
52  Eigen_vec3 euler_angles(std::ptrdiff_t a0 = 0, std::ptrdiff_t a1 = 1, std::ptrdiff_t a2 = 2) const;
53 
54  std::string to_string() const;
55  static pose from_string(const std::string&);
56 
57  Eigen_vec3 transform_from_world(const Eigen::Vector3f& p) const {
58  return transformation_from_world() * p;
59  }
60 
61  Eigen_vec3 transform_to_world(const Eigen::Vector3f& p) const {
62  return transformation_to_world() * p;
63  }
64 
65  void look_at(const Eigen_vec3&);
66 
67  void flip(const Eigen_vec3& axis = Eigen_vec3::UnitY());
68  void invert_orientation();
69 };
70 
71 
72 std::ostream& operator<<(std::ostream&, const pose&);
73 
74 }
75 
76 #endif
Eigen_affine3 transformation_from_world() const
Affine transformation from world space to pose coordinate system.
Definition: pose.cc:26
Eigen_affine3 transformation_to_world() const
Affine transformation from pose coordinate system to world space.
Definition: pose.cc:30
Eigen_vec3 euler_angles(std::ptrdiff_t a0=0, std::ptrdiff_t a1=1, std::ptrdiff_t a2=2) const
Definition: pose.cc:34
Eigen_quaternion orientation
Orientation quaternion. Must be kept normalized.
Definition: pose.h:18
static pose from_string(const std::string &)
Definition: pose.cc:58
pose()
Create identity pose.
Definition: pose.cc:12
Eigen_affine3 transformation_to(const pose &ps) const
Definition: pose.h:48
Eigen::Transform< Eigen_scalar, 3, Eigen::Affine > Eigen_affine3
Definition: eigen.h:37
void look_at(const Eigen_vec3 &)
Definition: pose.cc:69
Eigen_vec3 transform_to_world(const Eigen::Vector3f &p) const
Definition: pose.h:61
Position and orientation in space.
Definition: pose.h:15
Eigen::Quaternion< Eigen_scalar > Eigen_quaternion
Definition: eigen.h:45
void flip(const Eigen_vec3 &axis=Eigen_vec3::UnitY())
Definition: pose.cc:76
Eigen_vec3 position
Position vector.
Definition: pose.h:17
pose(const Translation &t, const Rotation &r)
Construct pose with given translation and rotation.
Definition: pose.h:34
Eigen_affine3 transformation_from(const pose &ps) const
Definition: pose.h:44
Eigen_vec3 transform_from_world(const Eigen::Vector3f &p) const
Definition: pose.h:57
std::string to_string() const
Definition: pose.cc:46
void invert_orientation()
Definition: pose.cc:81
Eigen_mat< 3, 1 > Eigen_vec3
Definition: eigen.h:25
std::ostream & operator<<(std::ostream &str, const time_span &span)
Definition: common.h:76