-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrixVector.cpp
104 lines (92 loc) · 2.28 KB
/
MatrixVector.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 "include/MatrixVector.h"
// MatrixVector3
MatrixVector3::MatrixVector3()
{
this->x = 0;
this->y = 0;
this->z = 0;
}
MatrixVector3::MatrixVector3(int x, int y, int z)
{
this->x = x;
this->y = y;
this->z = z;
}
std::string MatrixVector3::str() { return "(" + std::to_string(x) + ", " + std::to_string(y) + "," + std::to_string(z) + ")"; }
MatrixVector3 MatrixVector3::operator+(MatrixVector3& other)
{
return MatrixVector3{ x + other.x, y + other.y, z + other.z };
}
MatrixVector3 MatrixVector3::operator-(MatrixVector3& other)
{
return MatrixVector3{ x - other.x, y - other.y, z - other.z };
}
MatrixVector3 MatrixVector3::operator/(int div)
{
return MatrixVector3{ x / div, y / div, z / div };
}
MatrixVector3 MatrixVector3::operator<<(std::ostream& os)
{
os << "(" << x << ", " << y << ", " << z << ")";
return *this;
}
MatrixVector3 MatrixVector3::operator+= (MatrixVector3& other)
{
x += other.x;
y += other.y;
z += other.z;
return *this;
}
bool MatrixVector3::operator!=(MatrixVector3& other)
{
return x != other.x || y != other.y || z != other.z;
}
bool MatrixVector3::operator==(MatrixVector3& other)
{
return x == other.x && y == other.y && z == other.z;
}
// end MatrixVector3
// MatrixVector2
MatrixVector2::MatrixVector2()
{
this->x = 0;
this->y = 0;
}
MatrixVector2::MatrixVector2(int x, int y)
{
this->x = x;
this->y = y;
}
std::string MatrixVector2::str() { return "(" + std::to_string(x) + ", " + std::to_string(y) + ")"; }
MatrixVector2 MatrixVector2::operator+(MatrixVector2& other)
{
return MatrixVector2{ x + other.x, y + other.y };
}
MatrixVector2 MatrixVector2::operator-(MatrixVector2& other)
{
return MatrixVector2{ x - other.x, y - other.y };
}
MatrixVector2 MatrixVector2::operator/(int div)
{
return MatrixVector2{ x / div, y / div };
}
std::ostream& MatrixVector2::operator<<(std::ostream& os)
{
os << "(" << x << ", " << y << ")";
return os;
}
MatrixVector2 MatrixVector2::operator+= (MatrixVector2& other)
{
x += other.x;
y += other.y;
return *this;
}
bool MatrixVector2::operator!=(MatrixVector2& other)
{
return x != other.x || y != other.y;
}
bool MatrixVector2::operator==(MatrixVector2& other)
{
return x == other.x && y == other.y;
}
// end MatrixVector2