hom_pose.cpp

00001 
00002 /***************************************************************************
00003  *  hom_pose.cpp - Homogenous Pose
00004  *
00005  *  Created: Sun April 13 17:52:43 2008
00006  *  Copyright  2008  Daniel Beck
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #include <geometry/hom_pose.h>
00025 
00026 namespace fawkes {
00027 
00028 /** @class HomPose <geometry/hom_pose.h>
00029  * A homogeneous pose combines a position with an orienation in space.
00030  * @author Daniel Beck
00031  */
00032 
00033 /** Constructor.
00034  * Constructs a two-dimensional pose.
00035  * @param x the x-coordinate of the position
00036  * @param y the y-coordinate of the position
00037  * @param yaw the orienations in the xy-plane
00038  */
00039 HomPose::HomPose(float x, float y, float yaw)
00040   : HomPoint(x, y)
00041 {
00042   m_roll  = 0.0;
00043   m_pitch = 0.0;
00044   m_yaw   = yaw;
00045 }
00046 
00047 /** Constructor.
00048  * Constructs a three-dimensional pose.
00049  * @param x the x-coordinate of the position
00050  * @param y the y-coordinate of the position
00051  * @param z the z-coordinate of the position
00052  * @param roll the orienations in the yz-plane
00053  * @param pitch the orienations in the xz-plane
00054  * @param yaw the orienations in the xy-plane
00055  */
00056 HomPose::HomPose(float x, float y, float z, float roll, float pitch, float yaw)
00057   : HomPoint(x, y, z)
00058 {
00059   m_roll  = roll;
00060   m_pitch = pitch;
00061   m_yaw   = yaw;
00062 }
00063 
00064 /** Copy constructor.
00065  * @param h a homogeneous coordinate
00066  */
00067 HomPose::HomPose(const HomCoord& h)
00068   : HomPoint(h)
00069 {
00070   m_roll  = 0.0;
00071   m_pitch = 0.0;
00072   m_yaw   = 0.0;
00073 }
00074 
00075 /** Destructor. */
00076 HomPose::~HomPose()
00077 {
00078 }
00079 
00080 /** RO-getter for roll.
00081  * @return the value
00082  */
00083 float
00084 HomPose::roll() const
00085 {
00086   return m_roll;
00087 }
00088 
00089 /** RW-getter for roll.
00090  * @return a reference to the roll variable
00091  */
00092 float&
00093 HomPose::roll()
00094 {
00095   return m_roll;
00096 }
00097 
00098 /** Setter function for roll.
00099  * @param roll the new roll value
00100  */
00101 void
00102 HomPose::roll(float roll)
00103 {
00104   m_roll = roll;
00105 }
00106 
00107 /** RO-getter for pitch.
00108  * @return the value
00109  */
00110 float
00111 HomPose::pitch() const
00112 {
00113   return m_pitch;
00114 }
00115 
00116 /** RW-getter for pitch.
00117  * @return a reference to the pitch variable
00118  */
00119 float&
00120 HomPose::pitch()
00121 {
00122   return m_pitch;
00123 }
00124 
00125 /** Setter function for pitch.
00126  * @param pitch the new pitch value
00127  */
00128 void
00129 HomPose::pitch(float pitch)
00130 {
00131   m_pitch = pitch;
00132 }
00133 
00134 /** RO-getter for yaw.
00135  * @return the value
00136  */
00137 float
00138 HomPose::yaw() const
00139 {
00140   return m_yaw;
00141 }
00142 
00143 /** RW-getter for yaw.
00144  * @return a reference to the yaw variable
00145  */
00146 float&
00147 HomPose::yaw()
00148 {
00149   return m_yaw;
00150 }
00151 
00152 /** Setter function for yaw.
00153  * @param yaw the new yaw value
00154  */
00155 void
00156 HomPose::yaw(float yaw)
00157 {
00158   m_yaw = yaw;
00159 }
00160 
00161 /** Get the positional part of the pose.
00162  * @return the position
00163  */
00164 HomPoint
00165 HomPose::pos() const
00166 {
00167   HomPoint pos;
00168   pos.x() = x();
00169   pos.y() = y();
00170   pos.z() = z();
00171 
00172   return pos;
00173 }
00174 
00175 HomPose&
00176 HomPose::rotate_x(float rad)
00177 {
00178   HomCoord::rotate_x(rad);
00179   m_roll += rad;
00180 
00181   return *this;
00182 }
00183 
00184 HomPose&
00185 HomPose::rotate_y(float rad)
00186 {
00187   HomCoord::rotate_y(rad);
00188   m_roll += rad;
00189 
00190   return *this;
00191 }
00192 
00193 HomPose&
00194 HomPose::rotate_z(float rad)
00195 {
00196   HomCoord::rotate_z(rad);
00197   m_roll += rad;
00198 
00199   return *this;
00200 }
00201 
00202 } // end namespace fawkes

Generated on Tue Feb 22 13:32:27 2011 for Fawkes API by  doxygen 1.4.7