-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCoord.cpp
82 lines (80 loc) · 1.34 KB
/
Coord.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
#include <iostream>
#include "Coord.h"
using namespace std;
Coord::Coord() {
x = 0;
y = 0;
z = 0;
}
Coord::Coord(int i, int j, int k) {
x = i;
y = j;
z = k;
}
Coord::Coord(double i, double j, double k) {
x = i;
y = j;
z = k;
}
Coord Coord::operator+(const Coord& c) const {
Coord cNew;
cNew.x = c.x + x;
cNew.y = c.y + y;
cNew.z = c.z + z;
return cNew;
}
Coord Coord::operator/(const Coord& c) const {
Coord cNew;
cNew.x = x / c.x;
cNew.y = y / c.y;
cNew.z = z / c.z;
return cNew;
}
Coord Coord::operator*(const Coord& c) const {
Coord cNew;
cNew.x = c.x * x;
cNew.y = c.y * y;
cNew.z = c.z * z;
return cNew;
}
Coord Coord::operator-(const Coord& c) const {
Coord cNew;
cNew.x = x - c.x;
cNew.y = y - c.y;
cNew.z = z - c.z;
return cNew;
}
Coord Coord::operator=(const Coord& c) {
x = c.x;
y = c.y;
z = c.z;
return *this;
}
Coord Coord::operator/(const double& i) const {
Coord cNew;
cNew.x = x / i;
cNew.y = y / i;
cNew.z = z / i;
return cNew;
}
Coord Coord::operator*(const double& i) const {
Coord cNew;
cNew.x = x * i;
cNew.y = y * i;
cNew.z = z * i;
return cNew;
}
Coord Coord::operator+(const double& i) const {
Coord cNew;
cNew.x = x + i;
cNew.y = y + i;
cNew.z = z + i;
return cNew;
}
Coord Coord::operator-(const double& i) const {
Coord cNew;
cNew.x = x - i;
cNew.y = y - i;
cNew.z = z - i;
return cNew;
}