changed Vector.hh to work as coor.hh
authornireco
Tue, 18 Nov 2008 19:05:35 +0000
changeset 53 a76ddb2e39fb
parent 52 8db6726c27fc
child 54 b8b043ba0abd
changed Vector.hh to work as coor.hh
src/proto2/Vector.hh
--- a/src/proto2/Vector.hh	Tue Nov 18 19:03:09 2008 +0000
+++ b/src/proto2/Vector.hh	Tue Nov 18 19:05:35 2008 +0000
@@ -1,20 +1,48 @@
-#ifndef VECTOR_HH
-#define VECTOR_HH
-
-#include <complex>
+#ifndef COOR_H
+#define COOR_H
 
-class Vector : std::complex<float> {
+//#define TYPE double
 
+template <typename TYPE>
+class coor {
 public:
-    Vector(float x, float y) : std::complex<float> (x, y) {}
-
-    float x() const {
-	return this->real();
+    TYPE x;
+    TYPE y;
+    coor() {
+        x = 0; y = 0;
+    }
+    coor(TYPE X, TYPE Y) {
+        x = X;
+        y = Y;
+    }
+    coor(const coor& c) {
+        x = c.x;
+        y = c.y;
+    }
+    void operator = (const coor& c) {
+        x = c.x;
+        y = c.y;
+    }
+    coor operator + (const coor& c) {
+        return coor(x+c.x, y+c.y);
+    }
+    coor operator - (const coor& c) {
+        return coor(x-c.x, y-c.y);
+    }
+    void operator += (const coor& c) {
+        x += c.x;
+        y += c.y;
     }
 
-    float y() const {
-	return this->imag();
+    coor operator * (const double d) {
+        return coor(x*d, y*d);
     }
+
 };
 
+template<typename T>
+bool operator== (const coor<T>& c1, const coor<T>& c2) {
+    return ((c1.x == c2.x) && (c1.y == c2.y));
+}
+
 #endif