-
Notifications
You must be signed in to change notification settings - Fork 0
/
point.cpp
104 lines (89 loc) · 1.5 KB
/
point.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
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
102
103
104
#include "!_All_include.h"
#include "point.h"
point::point()
{
_x = 0;
_y = 0;
_z = 0;
}
point::point(double x, double y, double z): _x(x), _y(y), _z(z)
{
}
double point::GetX() const
{
return _x;
}
double point::GetY() const
{
return _y;
}
double point::GetZ() const
{
return _z;
}
bool point::operator <=(const point& b) const
{
if (GetZ() < b.GetZ())
return true;
if (GetZ() == b.GetZ())
{
if (GetX() < b.GetX())
return true;
if (GetX() == b.GetX())
if (GetY() <= b.GetY())
return true;
}
return false;
}
const point point::operator +(const point b) const
{
point c;
c.SetX(GetX() + b.GetX());
c.SetY(GetY() + b.GetY());
c.SetZ(GetZ() + b.GetZ());
return c;
}
const point point::operator -(const point b) const
{
point c;
c.SetX(GetX() - b.GetX());
c.SetY(GetY() - b.GetY());
c.SetZ(GetZ() - b.GetZ());
return c;
}
const point point::operator -() const
{
point b;
b.SetX(-GetX());
b.SetY(-GetY());
b.SetZ(-GetZ());
return b;
}
void point::SetX(double x)
{
_x = x;
}
void point::SetY(double y)
{
_y = y;
}
void point::SetZ(double z)
{
_z = z;
}
void point::SetCoor(double x, double y, double z){
SetX(x);
SetY(y);
SetZ(z);
}
std::istream& operator >> (std::istream& in, point& p)
{
int draft;
in >> draft;
p.SetX(draft);
in >> draft;
p.SetY(draft);
in >> draft;
p.SetZ(draft);
return in;
}