blob: caeb6f7d28f04379bd545108c2ab02f776fc8f07 (
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
|
#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& vertex1, const Vertex& vertex2) :
v1(vertex1), v2(vertex2) {}
Line(float x1, float y1, float x2, float y2) :
v1(x1, y1), v2(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;}
float lengthSq() const {return v1.distanceSq(v2);}
float length() const {return sqrtf(lengthSq());}
bool contains(const Vertex &v) const;
int intersects(const Line &l, Vertex *v) const;
};
#endif /*LINE_H_*/
|