summaryrefslogtreecommitdiff
path: root/engine/vector.cpp
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-05-23 22:36:59 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-05-23 22:36:59 +0200
commit12f709042181115db56bf7fc6e234aaaed751b9d (patch)
treeeff465105054c02c9ef4fdbc4da5e1e3e2fce807 /engine/vector.cpp
parentf2d3072643e4140ef3dd144b7509eda8d4a323d6 (diff)
Added operator overloaders to vector classes.
Diffstat (limited to 'engine/vector.cpp')
-rw-r--r--engine/vector.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/engine/vector.cpp b/engine/vector.cpp
index c23466e..6c71991 100644
--- a/engine/vector.cpp
+++ b/engine/vector.cpp
@@ -26,6 +26,20 @@ Vector2& Vector2::operator+=(const Vector2& v) {
return *this;
}
+Vector2& Vector2::operator+(const Vector2& v) {
+ return Vector2(*this) += v;
+}
+
+Vector2& Vector2::operator-=(const Vector2& v) {
+ x -= v.x;
+ y -= v.y;
+ return *this;
+}
+
+Vector2& Vector2::operator-(const Vector2& v) {
+ return Vector2(*this) -= v;
+}
+
Vector3::Vector3() : Vector2() {
z = 0;
}
@@ -49,6 +63,28 @@ Vector3& Vector3::operator=(const Vector3& v) {
return *this;
}
+Vector3& Vector3::operator+=(const Vector3& v) {
+ x += v.x;
+ y += v.y;
+ z += v.z;
+ return *this;
+}
+
+Vector3& Vector3::operator+(const Vector3& v) {
+ return Vector3(*this) += v;
+}
+
+Vector3& Vector3::operator-=(const Vector3& v) {
+ x -= v.x;
+ y -= v.y;
+ z -= v.z;
+ return *this;
+}
+
+Vector3& Vector3::operator-(const Vector3& v) {
+ return Vector3(*this) -= v;
+}
+
Vector4::Vector4() : Vector3() {
w = 0;
}
@@ -71,3 +107,27 @@ Vector4& Vector4::operator=(const Vector4& v) {
w = v.w;
return *this;
}
+
+Vector4& Vector4::operator+=(const Vector4& v) {
+ x += v.x;
+ y += v.y;
+ z += v.z;
+ w += v.w;
+ return *this;
+}
+
+Vector4& Vector4::operator+(const Vector4& v) {
+ return Vector4(*this) += v;
+}
+
+Vector4& Vector4::operator-=(const Vector4& v) {
+ x -= v.x;
+ y -= v.y;
+ z -= v.z;
+ w -= v.w;
+ return *this;
+}
+
+Vector4& Vector4::operator-(const Vector4& v) {
+ return Vector4(*this) -= v;
+}