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

ArTransform.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
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 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARTRANSFORM_H
00027 #define ARTRANSFORM_H
00028 
00029 #include "ariaTypedefs.h"
00030 #include "ariaUtil.h"
00031 
00033 
00034 class ArTransform
00035 {
00036 public:
00038   ArTransform() 
00039     { 
00040       myX = 0;
00041       myY = 0; 
00042       myTh = 0;
00043       myCos = ArMath::cos(myTh);
00044       mySin = ArMath::sin(myTh);
00045     }
00048 
00049   ArTransform(ArPose pose) 
00050     { 
00051       setTransform(pose);
00052     }
00055   ArTransform(ArPose pose1, ArPose pose2)
00056     {
00057       setTransform(pose1, pose2);
00058     }
00060   virtual ~ArTransform() {}
00061 
00064 
00068   ArPose doTransform(ArPose source)
00069     {
00070       ArPose ret;
00071       ret.setX(myX + myCos * source.getX() + mySin * source.getY());
00072       ret.setY(myY + myCos * source.getY() - mySin * source.getX());
00073       ret.setTh(ArMath::addAngle(source.getTh(),myTh));      
00074       return ret;
00075     }
00078 
00082   ArPoseWithTime doTransform(ArPoseWithTime source)
00083     {
00084       ArPoseWithTime ret;
00085       ret.setX(myX + myCos * source.getX() + mySin * source.getY());
00086       ret.setY(myY + myCos * source.getY() - mySin * source.getX());
00087       ret.setTh(ArMath::addAngle(source.getTh(),myTh));      
00088       ret.setTime(source.getTime());
00089       return ret;
00090     }
00091 
00094 
00099   AREXPORT ArPose doInvTransform(ArPose source)
00100     {
00101       ArPose ret;
00102       double tx = source.getX() - myX;
00103       double ty = source.getY() - myY;
00104       ret.setX(myCos * tx - mySin * ty);
00105       ret.setY(myCos * ty + mySin * tx);
00106       ret.setTh(ArMath::subAngle(source.getTh(),myTh));      
00107       return ret;
00108     }
00109 
00112 
00117   AREXPORT ArPoseWithTime doInvTransform(ArPoseWithTime source)
00118     {
00119       ArPoseWithTime ret;
00120       double tx = source.getX() - myX;
00121       double ty = source.getY() - myY;
00122       ret.setX(myCos * tx - mySin * ty);
00123       ret.setY(myCos * ty + mySin * tx);
00124       ret.setTh(ArMath::subAngle(source.getTh(),myTh));      
00125       ret.setTime(source.getTime());
00126       return ret;
00127     }
00128 
00129 
00131   AREXPORT void doTransform(std::list<ArPose *> *poseList);
00133   AREXPORT void doTransform(std::list<ArPoseWithTime *> *poseList);
00135   AREXPORT void setTransform(ArPose pose);
00137   AREXPORT void setTransform(ArPose pose1, ArPose pose2);
00139   double getTh() { return myTh; }
00140 
00141 protected:
00142   double myX;
00143   double myY;
00144   double myTh;
00145   double myCos;
00146   double mySin;
00147 };
00148 
00149 
00150 #endif // ARTRANSFORM_H

Generated on Tue Feb 20 10:51:41 2007 for Aria by  doxygen 1.4.0