Ravelin
Pose2.h
1 /****************************************************************************
2  * Copyright 2013 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef POSE2
8 #error This class is not to be included by the user directly. Use Posed.h or Posef.h instead.
9 #endif
10 
12 class POSE2 : public boost::enable_shared_from_this<POSE2>
13 {
14  public:
15  POSE2();
16  POSE2(const POSE2& source) { operator=(source); }
17  POSE2(const ROT2& r, const ORIGIN2& x, boost::shared_ptr<const POSE2> relative_pose = boost::shared_ptr<const POSE2>());
18  POSE2(const ORIGIN2& x, boost::shared_ptr<const POSE2> relative_pose = boost::shared_ptr<const POSE2>());
19  POSE2(const ROT2& r, boost::shared_ptr<const POSE2> relative_pose = boost::shared_ptr<const POSE2>());
20  static POSE2 identity() { POSE2 T; T.set_identity(); return T; }
21  static REAL wrap(REAL theta);
22  static bool rel_equal(const POSE2& p1, const POSE2& p2, REAL tol=EPS);
23  VECTOR2 transform_point(const VECTOR2& v) const;
24  VECTOR2 transform_vector(const VECTOR2& v) const;
25  VECTOR2 inverse_transform_point(const VECTOR2& v) const;
27  static VECTOR2 transform_point(boost::shared_ptr<const POSE2> target, const VECTOR2& v);
28  static VECTOR2 transform_vector(boost::shared_ptr<const POSE2> target, const VECTOR2& v);
30  POSE2& invert();
31  POSE2 inverse() const { return invert(*this); }
32  static POSE2 invert(const POSE2& m);
33  POSE2& set(const ROT2& r, const ORIGIN2& v);
34  POSE2& set(const ROT2& r);
35  POSE2& operator=(const POSE2& source);
36  POSE2 operator*(const POSE2& m) const;
37  static VECTOR2 interpolate_transform_vector(const POSE2& P1, const POSE2& P2, REAL t, const ORIGIN2& o);
38  static VECTOR2 interpolate_transform_point(const POSE2& P1, const POSE2& P2, REAL t, const ORIGIN2& o);
39 
42 
45 
47  boost::shared_ptr<const POSE2> rpose;
48 
49  private:
50  TRANSFORM2 calc_transform(boost::shared_ptr<const POSE2> p) const;
51  static TRANSFORM2 calc_transform(boost::shared_ptr<const POSE2> source, boost::shared_ptr<const POSE2> target);
52  static bool is_common(boost::shared_ptr<const POSE2> source, boost::shared_ptr<const POSE2> p, unsigned& i);
53 }; // end class
54 
55 std::ostream& operator<<(std::ostream& out, const POSE2& m);
56 
A 2D rigid body pose.
Definition: Pose2.h:12
A two-dimensional floating point vector used for computational geometry calculations and with associa...
Definition: Vector2.h:15
static bool rel_equal(const POSE2 &p1, const POSE2 &p2, REAL tol=EPS)
Determines whether two poses in 2D are relatively equivalent.
Definition: Pose2.cpp:69
POSE2()
Default constructor.
Definition: Pose2.cpp:11
VECTOR2 transform_point(const VECTOR2 &v) const
Transforms a point from one pose to another.
Definition: Pose2.cpp:210
static REAL wrap(REAL theta)
Wraps an angle to [-pi, pi].
Definition: Pose2.cpp:46
static VECTOR2 interpolate_transform_vector(const POSE2 &P1, const POSE2 &P2, REAL t, const ORIGIN2 &o)
Tranforms a vector with an interpolated pose (between poses P1 and P2)
Definition: Pose2.cpp:93
POSE2 & invert()
Special method for inverting a 2D pose in place.
Definition: Pose2.cpp:278
POSE2 & set_identity()
Sets this matrix to identity.
Definition: Pose2.cpp:157
VECTOR2 inverse_transform_vector(const VECTOR2 &v) const
Transforms a vector from one pose to another.
Definition: Pose2.cpp:187
ORIGIN2 x
the position of the pose frame
Definition: Pose2.h:44
boost::shared_ptr< const POSE2 > rpose
the pose that this pose is relative to (if any)
Definition: Pose2.h:47
Represents an orientation in 2D.
Definition: Rot2.h:12
POSE2 operator*(const POSE2 &m) const
Transforms this pose by another.
Definition: Pose2.cpp:296
POSE2 & set(const ROT2 &r, const ORIGIN2 &v)
Sets the pose from a rotation and translation vector.
Definition: Pose2.cpp:141
static VECTOR2 interpolate_transform_point(const POSE2 &P1, const POSE2 &P2, REAL t, const ORIGIN2 &o)
Tranforms a point with an interpolated pose (between poses P1 and P2)
Definition: Pose2.cpp:119
VECTOR2 inverse_transform_point(const VECTOR2 &v) const
Transforms a point from one pose to another.
Definition: Pose2.cpp:232
A two-dimensional floating point vector used for computational geometry calculations and without asso...
Definition: Origin2.h:14
VECTOR2 transform_vector(const VECTOR2 &v) const
Transforms a vector from one pose to another.
Definition: Pose2.cpp:165
A transformation between 2D rigid body poses.
Definition: Transform2.h:14
ROT2 r
the orientation of the pose frame
Definition: Pose2.h:41