Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

ArTransform.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #ifndef ARTRANSFORM_H
00028 #define ARTRANSFORM_H
00029 
00030 #include "ariaTypedefs.h"
00031 #include "ariaUtil.h"
00032 
00034 
00035 class ArTransform
00036 {
00037 public:
00039   ArTransform() 
00040     { 
00041       myX = 0;
00042       myY = 0; 
00043       myTh = 0;
00044       myCos = ArMath::cos(myTh);
00045       mySin = ArMath::sin(myTh);
00046     }
00049 
00050   ArTransform(ArPose pose) 
00051     { 
00052       setTransform(pose);
00053     }
00056   ArTransform(ArPose pose1, ArPose pose2)
00057     {
00058       setTransform(pose1, pose2);
00059     }
00061   virtual ~ArTransform() {}
00062 
00065 
00069   ArPose doTransform(ArPose source)
00070     {
00071       ArPose ret;
00072       ret.setX(myX + myCos * source.getX() + mySin * source.getY());
00073       ret.setY(myY + myCos * source.getY() - mySin * source.getX());
00074       ret.setTh(ArMath::addAngle(source.getTh(),myTh));      
00075       return ret;
00076     }
00079 
00083   ArPoseWithTime doTransform(ArPoseWithTime source)
00084     {
00085       ArPoseWithTime ret;
00086       ret.setX(myX + myCos * source.getX() + mySin * source.getY());
00087       ret.setY(myY + myCos * source.getY() - mySin * source.getX());
00088       ret.setTh(ArMath::addAngle(source.getTh(),myTh));      
00089       ret.setTime(source.getTime());
00090       return ret;
00091     }
00092 
00095 
00100   ArPose doInvTransform(ArPose source)
00101     {
00102       ArPose ret;
00103       double tx = source.getX() - myX;
00104       double ty = source.getY() - myY;
00105       ret.setX(myCos * tx - mySin * ty);
00106       ret.setY(myCos * ty + mySin * tx);
00107       ret.setTh(ArMath::subAngle(source.getTh(),myTh));      
00108       return ret;
00109     }
00110 
00113 
00118   ArPoseWithTime doInvTransform(ArPoseWithTime source)
00119     {
00120       ArPoseWithTime ret;
00121       double tx = source.getX() - myX;
00122       double ty = source.getY() - myY;
00123       ret.setX(myCos * tx - mySin * ty);
00124       ret.setY(myCos * ty + mySin * tx);
00125       ret.setTh(ArMath::subAngle(source.getTh(),myTh));      
00126       ret.setTime(source.getTime());
00127       return ret;
00128     }
00129 
00130 
00132   void doTransform(std::list<ArPose *> *poseList);
00134   void doTransform(std::list<ArPoseWithTime *> *poseList);
00136   void setTransform(ArPose pose);
00138   void setTransform(ArPose pose1, ArPose pose2);
00140   double getTh() { return myTh; }
00141 
00142 protected:
00143   double myX;
00144   double myY;
00145   double myTh;
00146   double myCos;
00147   double mySin;
00148 };
00149 
00150 
00151 #endif // ARTRANSFORM_H

Generated on Wed Oct 19 12:56:37 2005 for Aria by  doxygen 1.4.0