-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector.cpp
More file actions
60 lines (47 loc) · 916 Bytes
/
Vector.cpp
File metadata and controls
60 lines (47 loc) · 916 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "Vector.h"
Vector::Vector() {
this->x = 0;
this->y = 0;
this->z = 0;
}
Vector::Vector(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
}
Vector::Vector(const Vector& orig) {
this->x = orig.x;
this->y = orig.y;
this->z = orig.z;
}
Vector Vector::operator+(Vector& other) {
Vector result(this->x + other.x, this->y + other.y, this->z + other.z);
return result;
}
Vector& Vector::operator +=(Vector& other) {
*this = *this + other;
return *this;
}
float Vector::getX() const {
return x;
}
float Vector::getY() const {
return y;
}
float Vector::getZ() const {
return z;
}
void Vector::setX(float x) {
this->x = x;
}
void Vector::setY(float y) {
this->y = y;
}
void Vector::setZ(float z) {
this->z = z;
}
void Vector::set(float x, float y, float z) {
this->x = x;
this->y = y;
this->z = z;
}