blob: 18f714c639e97e17aa1fa3e0cc67996bc91d8eb8 (
plain)
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
|
#ifndef LINE_H_
#define LINE_H_
#include "Vertex.h"
#include <math.h>
#define INTERSECTION_ERROR -1
#define INTERSECTION_NONE 0
#define INTERSECTION_IDENTICAL 1
#define INTERSECTION_LINE 2
#define INTERSECTION_LINE_LINE 2
#define INTERSECTION_LINE_SEGMENT 3
#define INTERSECTION_SEGMENT_LINE 6
#define INTERSECTION_SEGMENT_SEGMENT 7
class Line {
private:
Vertex v1, v2;
public:
Line() {}
Line(const Vertex& v1, const Vertex& v2) {
this->v1 = v1; this->v2 = v2;
}
Line(double x1, double y1, double x2, double y2) {
v1.setLocation(x1, y1);
v2.setLocation(x2, y2);
}
Vertex &getVertex1() {return v1;}
const Vertex &getVertex1() const {return v1;}
void setVertex1(const Vertex &v) {v1 = v;}
Vertex &getVertex2() {return v2;}
const Vertex &getVertex2() const {return v2;}
void setVertex2(const Vertex &v) {v2 = v;}
double lengthSq() const {return v1.distanceSq(v2);}
double length() const {return sqrt(lengthSq());}
bool contains(const Vertex &v) const;
int intersects(const Line &l, Vertex *v) const;
};
#endif /*LINE_H_*/
|