-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector2.cpp
More file actions
43 lines (33 loc) · 835 Bytes
/
vector2.cpp
File metadata and controls
43 lines (33 loc) · 835 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
#include "vector2.h"
namespace breakout {
Vector2& Vector2::operator += (const Vector2& rhs) {
x_ += rhs.x_;
y_ += rhs.y_;
return *this;
}
Vector2& Vector2::operator -= (const Vector2& rhs) {
x_ -= rhs.x_;
y_ -= rhs.y_;
return *this;
}
Vector2& Vector2::operator *= (double rhs) {
x_ *= rhs;
y_ *= rhs;
return *this;
}
Vector2 operator + (const Vector2& lhs, const Vector2& rhs) {
return Vector2(lhs) += rhs;
}
Vector2 operator - (const Vector2& lhs, const Vector2& rhs) {
return Vector2(lhs) -= rhs;
}
Vector2 operator * (const Vector2& lhs, double rhs) {
return Vector2(lhs) *= rhs;
}
Vector2 operator * (double lhs, const Vector2& rhs) {
return rhs * lhs;
}
bool operator == (const Vector2& lhs, const Vector2& rhs) {
return lhs.x() == rhs.x() && lhs.y() == rhs.y();
}
} // namespace breakout