-
Notifications
You must be signed in to change notification settings - Fork 2
/
polygon.h
executable file
·44 lines (36 loc) · 962 Bytes
/
polygon.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
#pragma once
#include "point.h"
#include "segment.h"
#include <vector>
class Polygon
{
public:
Polygon() = default;
Polygon(std::initializer_list<Point> points);
Polygon(const std::vector<Point>& points);
void AddPoint(const Point& point);
Point GetVertex(int num) const;
Point GetMassCenter() const;
enum class InsideStatus
{
INSIDE,
ON_BORDER,
OUTSIDE
};
InsideStatus GetInsideStatus(const Point& point) const;
int Size() const;
void SetRefractiveIndex(RealNumber refractive_index)
{
refractive_index_ = refractive_index;
}
RealNumber GetRefractiveIndex() const
{
return refractive_index_;
}
bool DoesSegmentIntersectPolygon(const Segment& segment) const;
private:
int CrossQty(const Segment& segment) const;
bool IsPointOnBorder(const Point& point) const;
std::vector<Point> vertices_;
RealNumber refractive_index_ = 0;
};