location.hpp

00001 
00002 #ifndef LOCATION_H
00003 #define LOCATION_H
00004 
00005 #include <iostream>
00006 using namespace std;
00007 #include <math.h>
00008 #include <boost/shared_ptr.hpp>
00009 
00014 class Location {
00015 public:
00017    typedef boost::shared_ptr<Location> LocationPtr;
00018    
00021    Location();
00022 
00029    Location(float x, float y, float z);
00030 
00037    static inline float distance(const Location& loc1, 
00038       const Location& loc2);
00039 
00046    inline void setCoordinates(float x, float y, float z);
00047 
00052    inline float getX() const;
00053 
00058    inline float getY() const;
00059 
00064    inline float getZ() const;
00065 
00066 private:
00067 
00071    float m_xCoordinate;
00072 
00076    float m_yCoordinate;
00077 
00081    float m_zCoordinate;
00082 
00083 };
00084 typedef boost::shared_ptr<Location> LocationPtr;
00085 
00087 // Inline Functions
00089 
00090 inline float Location::distance(const Location& loc1, const Location& loc2)
00091 {
00092    float xDiff = loc1.getX() - loc2.getX();
00093    float yDiff = loc1.getY() - loc2.getY();
00094    float zDiff = loc1.getZ() - loc2.getZ();
00095    return sqrt(pow(xDiff, 2) + pow(yDiff, 2) + pow(zDiff, 2));
00096 }
00097 
00098 inline void Location::setCoordinates(float x, float y, float z)
00099 {
00100    m_xCoordinate = x;
00101    m_yCoordinate = y;
00102    m_zCoordinate = z;
00103 }
00104 
00105 inline float Location::getX() const
00106 {
00107    return m_xCoordinate;
00108 }
00109 
00110 inline float Location::getY() const
00111 {
00112    return m_yCoordinate;
00113 }
00114 
00115 inline float Location::getZ() const
00116 {
00117    return m_zCoordinate;
00118 }
00119 
00121 // Overloaded Operators
00123 
00124 inline ostream& operator<< (ostream& s, const Location& location)
00125 {
00126    return s << "(x=" << location.getX() << ", y=" << 
00127       location.getY() << ", z=" << location.getZ() << ")";
00128 }
00129 
00130 #endif // LOCATION_H
00131 

Generated on Tue Dec 12 17:04:38 2006 for rfidsim by  doxygen 1.4.7