-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (40 loc) · 902 Bytes
/
main.cpp
File metadata and controls
40 lines (40 loc) · 902 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
class Point {private:
double x, y, r, a;
public:
Point(double x, double y) : x(x), y(y) {
r = sqrt(x * x + y * y);
a = atan2(y, x);
}
double get_x() const {
return x;
}
double get_y() const {
return y;
}
double get_r() const {
return r;
}
double get_a() const {
return a;
}
void set_x(double new_x) {
x = new_x;
r = sqrt(x * x + y * y);
a = atan2(y, x);
}
void set_y(double new_y) {
y = new_y;
r = sqrt(x * x + y * y);
a = atan2(y, x);
}
void set_r(double new_r) {
r = new_r;
x = r * cos(a);
y = r * sin(a);
}
void set_a(double new_a) {
a = new_a;
x = r * cos(a);
y = r * sin(a);
}
};