-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVector3D.cpp
129 lines (109 loc) · 2.43 KB
/
Vector3D.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// Created by rcabido on 25/10/19.
//
#include "Vector3D.h"
//// MÉTODOS CLASE VECTOR3D ////
//* Constructores *//
Vector3D::Vector3D() {
x = y = z = 0.0;
}
Vector3D::Vector3D(const float &xCoord, const float &yCoord, const float &zCoord) {
x = xCoord;
y = yCoord;
z = zCoord;
}
//* Getters *//
float Vector3D::getX() const {
return this->x;
}
float Vector3D::getY() const {
return this->y;
}
float Vector3D::getZ() const {
return this->z;
}
//* Setters *//
void Vector3D::setX(const float &d) {
this->x = x;
}
void Vector3D::setY(const float &d) {
this->y = y;
}
void Vector3D::setZ(const float &d) {
this->z = z;
}
//* Operaciones *//
Vector3D Vector3D::add(const Vector3D &b) const {
Vector3D result;
result.x = x + b.x;
result.y = y + b.y;
result.z = z + b.z;
return result;
}
Vector3D Vector3D::substract(const Vector3D &b) const {
Vector3D result;
result.x = x - b.x;
result.y = y - b.y;
result.z = z - b.z;
return result;
}
Vector3D Vector3D::product(const float &b) const {
Vector3D result;
result.x = x * b;
result.y = y * b;
result.z = z * b;
return result;
}
Vector3D Vector3D::product(const Vector3D &b) const {
Vector3D result;
result.x = x * b.x;
result.y = y * b.y;
result.z = z * b.z;
return result;
}
//Sobrecarga de operadores
Vector3D Vector3D::operator+(const float &b) const {
Vector3D result;
result.x = x + b;
result.y = y + b;
result.z = z + b;
return result;
}
Vector3D Vector3D::operator+(const Vector3D &b) const {
Vector3D result;
result.x = x + b.x;
result.y = y + b.y;
result.z = z + b.z;
return result;
}
Vector3D Vector3D::operator-(const float &b) const {
Vector3D result;
result.x = x - b;
result.y = y - b;
result.z = z - b;
return result;
}
Vector3D Vector3D::operator-(const Vector3D &b) const {
Vector3D result;
result.x = x - b.x;
result.y = y - b.y;
result.z = z - b.z;
return result;
}
Vector3D Vector3D::operator*(const float &b) const {
Vector3D result;
result.x = x * b;
result.y = y * b;
result.z = z * b;
return result;
}
Vector3D Vector3D::operator*(const Vector3D &b) const {
Vector3D result;
result.x = x * b.x;
result.y = y * b.y;
result.z = z * b.z;
return result;
}
bool Vector3D::operator==(const Vector3D& b) const {
return this->x == b.x && this->y == b.y && this->z == b.z;
}