-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.cpp
More file actions
101 lines (86 loc) · 1.38 KB
/
point.cpp
File metadata and controls
101 lines (86 loc) · 1.38 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "point.h"
Point::Point()
{
_x=0;
_y=0;
}
Point::Point(double X,double Y)
{
_x=X;
_y=Y;
}
Point::Point(const Point& P)
{
_x=P._x;
_y=P._y;
}
double Point::GetX()
{
return _x;
}
double Point::GetY()
{
return _y;
}
void Point::SetX(double X)
{
_x=X;
}
void Point::SetY(double Y)
{
_y=Y;
}
Point Point::operator =(Point P)
{
_x=P.GetX();
_y=P.GetY();
return *this;
}
Point Point::operator +(Point P)
{
Point result;
result.SetX(P.GetX()+_x);
result.SetY(P.GetY()+_y);
return result;
}
Point Point::operator +=(Point P)
{
_x += P.GetX();
_y += P.GetY();
return *this;
}
Point Point::operator -(Point P)
{
Point result;
result.SetX(_x-P.GetX());
result.SetY(_y-P.GetY());
return result;
}
Point Point::operator *(double value)
{
Point result;
result.SetX(_x*value);
result.SetY(_y*value);
return result;
}
double Point::Distance(Point P)
{
double distance=0;
distance=sqrt((_x-P._x)*(_x-P._x)+(_y-P._y)*(_y-P._y));
return distance;
}
double Point::Slope(Point P)
{
double slope=0;
slope=(P.GetY()-_y)/(P.GetX()-_x);
return slope;
}
bool Point::isSame(Point P)
{
if(_x==P._x && _y==P._y){
return true;
}
else{
return false;
}
}