-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircle.cpp
51 lines (37 loc) · 827 Bytes
/
Circle.cpp
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
48
49
50
#include "Circle.h"
#include "Draw.h"
Circle2D::Circle2D(Circle2D& c) {
radius = c.radius;
position = c.position;
color = c.color;
points = c.points;
point_num = c.point_num;
}
void Circle2D::setPosition(Vec2 p) {
position = p;
}
Vec2 Circle2D::getPosition() {
return position;
}
void Circle2D::setRadius(double r) {
radius = r;
resetPoints();
}
bool Circle2D::checkPointInside(Vec2& v) {
Vec2 sub = getPosition() - v;
return radius * radius >= sub.normSquare();
}
Collider::Projection Circle2D::projectOn(Vec2& v) {
Collider::Projection p = { 0x7fffffff, -0x7fffffff };
double tmp = v * position;
p.min = tmp - radius;
p.max = tmp + radius;
return p;
}
void Circle2D::draw() {
auto sides = getAllSides();
//cout << sides.size() << endl;
for (auto s : sides) {
Draw::DrawLine(s, color);
}
}