aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/point.hpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/utils/point.hpp66
1 files changed, 59 insertions, 7 deletions
diff --git a/src/utils/point.hpp b/src/utils/point.hpp
index 7c1ec727..6618e285 100644
--- a/src/utils/point.hpp
+++ b/src/utils/point.hpp
@@ -29,18 +29,70 @@
namespace usdx
{
+ template <class T>
class Point
{
private:
- float x;
- float y;
+ T x;
+ T y;
+
public:
- Point(float x, float y);
- Point(const Point& point);
- Point& operator=(const Point& point);
+ Point(T x, T y):
+ x(x), y(y)
+ {
+ }
+
+ Point(const Point& point):
+ x(point.x), y(point.y)
+ {
+ }
+
+ Point& operator=(const Point& point)
+ {
+ x = point.x;
+ y = point.y;
+ return *this;
+ }
+
+
+ T get_x(void) const
+ {
+ return x;
+ }
+
+ T get_y(void) const
+ {
+ return y;
+ }
+
+
+ Point& operator+=(const Point &other)
+ {
+ x += other.x;
+ y += other.y;
+ return *this;
+ }
+
+ Point& operator-=(const Point &other)
+ {
+ x -= other.x;
+ y -= other.y;
+ return *this;
+ }
+
+ const Point operator+(const Point &other) const
+ {
+ Point<T> result(*this);
+ result += other;
+ return result;
+ }
- float get_x(void) const;
- float get_y(void) const;
+ const Point operator-(const Point &other) const
+ {
+ Point<T> result(*this);
+ result -= other;
+ return result;
+ }
};
};