blob: 3b167a496c75e970e692f8a3e33ad33499c4a5aa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
|