Fawkes API  Fawkes Development Version
hom_pose.cpp
1 
2 /***************************************************************************
3  * hom_pose.cpp - Homogenous Pose
4  *
5  * Created: Sun April 13 17:52:43 2008
6  * Copyright 2008 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <geometry/hom_pose.h>
25 
26 namespace fawkes {
27 
28 /** @class HomPose <geometry/hom_pose.h>
29  * A homogeneous pose combines a position with an orienation in space.
30  * @author Daniel Beck
31  */
32 
33 /** Constructor.
34  * Constructs a two-dimensional pose.
35  * @param x the x-coordinate of the position
36  * @param y the y-coordinate of the position
37  * @param yaw the orienations in the xy-plane
38  */
39 HomPose::HomPose(float x, float y, float yaw)
40  : HomPoint(x, y)
41 {
42  m_roll = 0.0;
43  m_pitch = 0.0;
44  m_yaw = yaw;
45 }
46 
47 /** Constructor.
48  * Constructs a three-dimensional pose.
49  * @param x the x-coordinate of the position
50  * @param y the y-coordinate of the position
51  * @param z the z-coordinate of the position
52  * @param roll the orienations in the yz-plane
53  * @param pitch the orienations in the xz-plane
54  * @param yaw the orienations in the xy-plane
55  */
56 HomPose::HomPose(float x, float y, float z, float roll, float pitch, float yaw)
57  : HomPoint(x, y, z)
58 {
59  m_roll = roll;
60  m_pitch = pitch;
61  m_yaw = yaw;
62 }
63 
64 /** Copy constructor.
65  * @param h a homogeneous coordinate
66  */
68  : HomPoint(h)
69 {
70  m_roll = 0.0;
71  m_pitch = 0.0;
72  m_yaw = 0.0;
73 }
74 
75 /** Destructor. */
77 {
78 }
79 
80 /** RO-getter for roll.
81  * @return the value
82  */
83 float
85 {
86  return m_roll;
87 }
88 
89 /** RW-getter for roll.
90  * @return a reference to the roll variable
91  */
92 float&
94 {
95  return m_roll;
96 }
97 
98 /** Setter function for roll.
99  * @param roll the new roll value
100  */
101 void
102 HomPose::roll(float roll)
103 {
104  m_roll = roll;
105 }
106 
107 /** RO-getter for pitch.
108  * @return the value
109  */
110 float
112 {
113  return m_pitch;
114 }
115 
116 /** RW-getter for pitch.
117  * @return a reference to the pitch variable
118  */
119 float&
121 {
122  return m_pitch;
123 }
124 
125 /** Setter function for pitch.
126  * @param pitch the new pitch value
127  */
128 void
129 HomPose::pitch(float pitch)
130 {
131  m_pitch = pitch;
132 }
133 
134 /** RO-getter for yaw.
135  * @return the value
136  */
137 float
139 {
140  return m_yaw;
141 }
142 
143 /** RW-getter for yaw.
144  * @return a reference to the yaw variable
145  */
146 float&
148 {
149  return m_yaw;
150 }
151 
152 /** Setter function for yaw.
153  * @param yaw the new yaw value
154  */
155 void
156 HomPose::yaw(float yaw)
157 {
158  m_yaw = yaw;
159 }
160 
161 /** Get the positional part of the pose.
162  * @return the position
163  */
164 HomPoint
166 {
167  HomPoint pos;
168  pos.x() = x();
169  pos.y() = y();
170  pos.z() = z();
171 
172  return pos;
173 }
174 
175 HomPose&
177 {
178  HomCoord::rotate_x(rad);
179  m_roll += rad;
180 
181  return *this;
182 }
183 
184 HomPose&
186 {
187  HomCoord::rotate_y(rad);
188  m_roll += rad;
189 
190  return *this;
191 }
192 
193 HomPose&
195 {
196  HomCoord::rotate_z(rad);
197  m_roll += rad;
198 
199  return *this;
200 }
201 
202 } // end namespace fawkes
virtual float y() const
RO-getter for y.
Definition: hom_coord.cpp:115
virtual HomCoord & rotate_x(float rad)
Convenience function to rotate the HomCoord around the x-axis.
Definition: hom_coord.cpp:206
virtual ~HomPose()
Destructor.
Definition: hom_pose.cpp:76
Fawkes library namespace.
virtual HomPose & rotate_y(float rad)
Convenience function to rotate the HomCoord around the y-axis.
Definition: hom_pose.cpp:185
virtual HomPose & rotate_z(float rad)
Convenience function to rotate the HomCoord around the z-axis.
Definition: hom_pose.cpp:194
A homogeneous pose combines a position with an orienation in space.
Definition: hom_pose.h:31
virtual HomCoord & rotate_y(float rad)
Convenience function to rotate the HomCoord around the y-axis.
Definition: hom_coord.cpp:220
A homogeneous point.
Definition: hom_point.h:33
float pitch() const
RO-getter for pitch.
Definition: hom_pose.cpp:111
virtual float z() const
RO-getter for z.
Definition: hom_coord.cpp:145
HomPoint pos() const
Get the positional part of the pose.
Definition: hom_pose.cpp:165
Base class for homogeneous primitives (vector and point).
Definition: hom_coord.h:34
float yaw() const
RO-getter for yaw.
Definition: hom_pose.cpp:138
float roll() const
RO-getter for roll.
Definition: hom_pose.cpp:84
virtual HomCoord & rotate_z(float rad)
Convenience function to rotate the HomCoord around the z-axis.
Definition: hom_coord.cpp:234
virtual HomPose & rotate_x(float rad)
Convenience function to rotate the HomCoord around the x-axis.
Definition: hom_pose.cpp:176
virtual float x() const
RO-getter for x.
Definition: hom_coord.cpp:85
HomPose(float x=0, float y=0, float yaw=0)
Constructor.
Definition: hom_pose.cpp:39