diff options
Diffstat (limited to 'labb7/src/Point.h')
| -rw-r--r-- | labb7/src/Point.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/labb7/src/Point.h b/labb7/src/Point.h new file mode 100644 index 0000000..3b167a4 --- /dev/null +++ b/labb7/src/Point.h @@ -0,0 +1,57 @@ +/*
+ * TDDD86 Pattern Recognition
+ * This file contains the declaration of the Point class.
+ * See Point.cpp for implementation of each member.
+ * Your code should work properly with an unmodified version of this file.
+ */
+
+#ifndef POINT_H
+#define POINT_H
+
+#include <iostream>
+#include <QGraphicsScene>
+using namespace std;
+
+static const int COORD_MAX = 32767; // max value of x and y coordinates
+
+/*
+ * Each Point object represents an immutable single point
+ * with integer coordinates in the Euclidean plane.
+ */
+class Point {
+public:
+
+ Point() = delete;
+ Point(unsigned int _x, unsigned int _y) : x(_x), y(_y){}
+
+ /**
+ * Slope between this point and p
+ *
+ * If the points are the same, negative infinity is returned
+ * If the line between the points is horizontal positive zero is returned
+ * If the line between the points is vertical positive infinity is returned
+ */
+ double slopeTo(const Point& p) const;
+ /**
+ * Draw point to scene
+ */
+ void draw(QGraphicsScene* scene) const;
+ /**
+ * Draw line from this point to p to scene
+ */
+ void lineTo(QGraphicsScene* scene, const Point& p) const;
+
+ /**
+ * Is this point lexicographically smaller than p?
+ * Comparing x-ccordinates and breaking ties by y-coordinates
+ */
+ bool operator<(const Point&) const;
+ bool operator>(const Point&) const;
+
+ friend ostream& operator<<(ostream&, const Point&);
+
+private:
+ unsigned int x, y; // position
+};
+
+#endif // POINT_H
|
