blob: 1619bb674c2af6cdd1ecc262518db22e08e265d2 (
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
45
46
47
48
49
50
51
52
53
54
|
#include "../include/point.hpp"
Point::Point(double x, double y) {
set(x, y);
}
void Point::set(double x, double y) {
set_x(x);
set_y(y);
}
void Point::set_x(double x) {
this->x = x;
calc_distance();
}
void Point::set_y(double y) {
this->y = y;
calc_distance();
}
void Point::origin_symmetry() {
set(-x, -y);
}
void Point::translate(Point p) {
set(x+p.x, y+p.y);
}
double Point::get_x() {
return x;
}
double Point::get_y() {
return y;
}
double Point::get_distance() {
return distance;
}
double Point::get_distance(Point p) {
return sqrt(pow(x-p.x, 2) + pow(y-p.y, 2));
}
std::string Point::str() {
std::stringstream ss;
ss << "(" << x << ", " << y << ")";
return ss.str();
}
void Point::calc_distance() {
distance = sqrt(pow(x, 2) + pow(y, 2));
}
|