Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

V2.h

Go to the documentation of this file.
00001 #ifndef HEADER_V2_H
00002 #define HEADER_V2_H
00003 
00004 #include "StringTool.h"
00005 
00006 #include <string>
00007 #include <assert.h>
00008 
00009 /**
00010  * Vector x,y.
00011  * Constant object.
00012  */
00013 class V2 {
00014     private:
00015         int m_x;
00016         int m_y;
00017     public:
00018         V2(int x, int y) { m_x = x; m_y = y; }
00019 
00020         inline int getX() const { return m_x; }
00021         inline int getY() const { return m_y; }
00022 
00023         V2 plus(const V2 &other) const
00024         {
00025             return V2(m_x + other.m_x, m_y + other.m_y);
00026         }
00027         V2 minus(const V2 &other) const
00028         {
00029             return V2(m_x - other.m_x, m_y - other.m_y);
00030         }
00031         V2 scale(int rate) const
00032         {
00033             return V2(m_x * rate, m_y * rate);
00034         }
00035         V2 shrink(int rate) const
00036         {
00037             assert(rate != 0);
00038             return V2(m_x / rate, m_y / rate);
00039         }
00040 
00041         std::string toString() const
00042         {
00043             return "[" + StringTool::toString(m_x)
00044                 + "," + StringTool::toString(m_y) + "]";
00045         }
00046 };
00047 
00048 #endif

Generated on Wed Jun 1 09:54:32 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2