-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGraphics.h
More file actions
42 lines (34 loc) · 864 Bytes
/
Graphics.h
File metadata and controls
42 lines (34 loc) · 864 Bytes
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
#include <vector>
namespace CG {
const float EPSILON = 1e-5;
const float INFINITY = 1e7;
struct Point {
Point() : x{0}, y{0} {};
Point(float f1, float f2) : x{f1}, y{f2} {};
float x;
float y;
bool operator<(Point);
bool operator==(Point);
};
struct LineSegment {
LineSegment(Point p, Point q) : begin{p}, end{q} {};
Point begin;
Point end;
float length();
bool pointOnLeft(Point p);
bool pointOnRight(Point p);
bool pointOnLine(Point p);
bool pointInSegment(Point p);
std::vector<float> equation();
bool intersects(LineSegment);
Point intersection(LineSegment);
};
struct Polygon {
Polygon() {};
Polygon(std::vector<Point>& v) : points{v} {};
std::vector<Point> points;
};
float dist(Point, Point);
Polygon ConvexHull(std::vector<Point>&);
std::vector<Point> Intersections(std::vector<LineSegment>&);
}