summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-05-23 18:28:50 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-05-23 18:28:50 +0200
commit57bf396ed52510fee5a34e479ca1f671faba2773 (patch)
tree4eb469aad6a2e6f6a06a707893c5fee48667053e /engine
parentc478aeeb9b7b40bfd3415500b4886c0c0542bc26 (diff)
Added Vector2.
Diffstat (limited to 'engine')
-rw-r--r--engine/vector.cpp32
-rw-r--r--engine/vector.h16
2 files changed, 39 insertions, 9 deletions
diff --git a/engine/vector.cpp b/engine/vector.cpp
index f2ce8d7..1d243dd 100644
--- a/engine/vector.cpp
+++ b/engine/vector.cpp
@@ -1,7 +1,27 @@
#include "vector.h"
-Vector3::Vector3() {
- x = y = z = 0;
+Vector2::Vector2() {
+ x = y = 0;
+}
+
+Vector2::Vector2(float p1, float p2) {
+ x = p1;
+ y = p2;
+}
+
+Vector2::Vector2(const Vector2& v) {
+ x = v.x;
+ y = v.y;
+}
+
+Vector2& Vector2::operator=(const Vector2& v) {
+ x = v.x;
+ y = v.y;
+ return *this;
+}
+
+Vector3::Vector3() : Vector2() {
+ z = 0;
}
Vector3::Vector3(float p1, float p2, float p3) {
@@ -11,13 +31,13 @@ Vector3::Vector3(float p1, float p2, float p3) {
}
Vector3::Vector3(const Vector3& v) {
- x = v.r;
+ x = v.x;
y = v.y;
z = v.z;
}
Vector3& Vector3::operator=(const Vector3& v) {
- x = v.r;
+ x = v.x;
y = v.y;
z = v.z;
return *this;
@@ -32,14 +52,14 @@ Vector4::Vector4(float p1, float p2, float p3, float p4) : Vector3(p1, p2, p3) {
}
Vector4::Vector4(const Vector4& v) {
- x = v.r;
+ x = v.x;
y = v.y;
z = v.z;
w = v.w;
}
Vector4& Vector4::operator=(const Vector4& v) {
- x = v.r;
+ x = v.x;
y = v.y;
z = v.z;
w = v.w;
diff --git a/engine/vector.h b/engine/vector.h
index 3c590c3..179674f 100644
--- a/engine/vector.h
+++ b/engine/vector.h
@@ -1,7 +1,7 @@
#ifndef _VECTOR_H_
#define _VECTOR_H_
-class Vector3 {
+class Vector2 {
public:
union {
float x, r;
@@ -9,14 +9,24 @@ class Vector3 {
union {
float y, g;
};
+
+ Vector2();
+ Vector2(float p1, float p2);
+ Vector2(const Vector2& v);
+
+ Vector2& operator=(const Vector2& v);
+};
+
+class Vector3 : public Vector2 {
+ public:
union {
float z, b;
};
-
+
Vector3();
Vector3(float p1, float p2, float p3);
Vector3(const Vector3& v);
-
+
Vector3& operator=(const Vector3& v);
};