summaryrefslogtreecommitdiffstats
path: root/kue/point.h
diff options
context:
space:
mode:
Diffstat (limited to 'kue/point.h')
-rw-r--r--kue/point.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/kue/point.h b/kue/point.h
new file mode 100644
index 00000000..c748e7d3
--- /dev/null
+++ b/kue/point.h
@@ -0,0 +1,32 @@
+#ifndef _POINT_H
+#define _POINT_H
+
+#include <math.h>
+
+// Point is just a point on a 2D plane
+class point {
+ public:
+ point(double x = 0.0, double y = 0.0);
+ ~point();
+
+ // Gets our position
+ double positionX() const { return _pos_x; }
+ double positionY() const { return _pos_y; }
+
+ // Sets our position
+ void setPositionX(double new_pos) {_pos_x = new_pos;}
+ void setPositionY(double new_pos) {_pos_y = new_pos;}
+ void setPosition(double new_x, double new_y) {_pos_x = new_x; _pos_y = new_y; }
+ void setPosition(const point &p) {_pos_x = p._pos_x; _pos_y = p._pos_y; }
+
+ // Finds the distance between us and another point
+ double distance(const point &other_point) const;
+ // Finds the angle between us and another point
+ double angle(const point &other_point) const { return atan2(other_point._pos_y - _pos_y, other_point._pos_x - _pos_x); }
+
+ protected:
+ double _pos_x;
+ double _pos_y;
+};
+
+#endif