-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathline.h
46 lines (35 loc) · 1.24 KB
/
line.h
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
#ifndef LINE_H
#define LINE_H
#include "vector.h"
#include <ostream>
class Line {
private:
double A, B, C;
Vector start, end;
public:
Line();
Line(const Vector &start, const Vector &end);
Line(double A, double B, double C);
Vector getStart() const;
Vector getEnd() const;
double length() const;
double squareLength() const;
Line reverse() const;
Vector getPointAlong(double t) const;
double getDistance(const Vector &point) const;
Vector getLineNearestPoint(const Vector &point) const;
Vector getSegmentNearestPoint(const Vector &point) const;
int pointSide(const Vector &point) const;
int crossLineSegment(const Line &line, Vector &result) const;
int crossSegmentSegment(const Line &line, Vector &result) const;
int crossLineLine(const Line &line, Vector &result) const;
static Line getBisector(const Line &l1, const Line &l2);
static double getTanAngle(const Line &l1, const Line &l2);
static Line directedLine(const Vector &p, const Vector &d);
friend std::ostream& operator<< (std::ostream &out, const Line &l)
{
out << "[" << l.A << ", " << l.B << ", " << l.C << "]-{" << l.start << ", " << l.end << "}";
return out;
}
};
#endif // LINE_H