-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVPoint.h
82 lines (66 loc) · 1.38 KB
/
VPoint.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#pragma once
#include <cmath>
#include <string>
using namespace std;
class VPoint {
private:
double x, y;
double height;
public:
VPoint();
VPoint(double x, double y);
VPoint(double x, double y, double heigh);
~VPoint();
double getX();
void setX(double x);
double getY();
void setY(double y);
double getHeight();
void setHeight(double height);
string toString();
bool operator==(const VPoint& other);
double distance(VPoint other);
};
VPoint::VPoint() {}
VPoint::VPoint(double x, double y) {
this->x = x;
this->y = y;
this->height = -99999;
}
VPoint::VPoint(double x, double y, double height) {
this->x = x;
this->y = y;
this->height = height;
}
VPoint::~VPoint() {}
double VPoint::getX() {
return this->x;
}
double VPoint::getY() {
return this->y;
}
double VPoint::getHeight() {
return this->height;
}
void VPoint::setX(double x) {
this->x = x;
}
void VPoint::setY(double y) {
this->y = y;
}
void VPoint::setHeight(double h) {
this->height = h;
}
string VPoint::toString() {
return "Point:" + to_string(x) + "," + to_string(y);
}
bool VPoint::operator==(const VPoint& other) {
const double eps = 1e-5;
return (double)abs(this->x - other.x) < eps &&
(double)abs(this->y - other.y) < eps;
}
double VPoint::distance(VPoint other){
double dx=this->x-other.getX();
double dy=this->y-other.getY();
return sqrt(dx*dx+dy*dy);
}