location.hpp

来自「RFID reader 语 tag 模拟器」· HPP 代码 · 共 83 行

HPP
83
字号
 #ifndef LOCATION_H #define LOCATION_H #include <iostream> using namespace std; #include <math.h> #include <boost/shared_ptr.hpp> class Location { public:    typedef boost::shared_ptr<Location> LocationPtr;    Location();    Location(float x, float y, float z);    static inline float distance(const Location& loc1,       const Location& loc2);    inline void setCoordinates(float x, float y, float z);    inline float getX() const;    inline float getY() const;    inline float getZ() const; private:    float m_xCoordinate;    float m_yCoordinate;    float m_zCoordinate; }; typedef boost::shared_ptr<Location> LocationPtr; // Inline Functions inline float Location::distance(const Location& loc1, const Location& loc2) {    float xDiff = loc1.getX() - loc2.getX();    float yDiff = loc1.getY() - loc2.getY();    float zDiff = loc1.getZ() - loc2.getZ();    return sqrt(pow(xDiff, 2) + pow(yDiff, 2) + pow(zDiff, 2)); } inline void Location::setCoordinates(float x, float y, float z) {    m_xCoordinate = x;    m_yCoordinate = y;    m_zCoordinate = z; } inline float Location::getX() const {    return m_xCoordinate; } inline float Location::getY() const {    return m_yCoordinate; } inline float Location::getZ() const {    return m_zCoordinate; } // Overloaded Operators inline ostream& operator<< (ostream& s, const Location& location) {    return s << "(x=" << location.getX() << ", y=" <<       location.getY() << ", z=" << location.getZ() << ")"; } #endif // LOCATION_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?