--- a/plan/diagram.dot Tue Nov 18 19:17:56 2008 +0000
+++ b/plan/diagram.dot Tue Nov 18 19:33:03 2008 +0000
@@ -19,7 +19,7 @@
subgraph cluster1 {
label = "Game Engine";
- {rank=min; gs; physics; }
+ {rank=min; gs; physics;}
gs;
physics;
color = black;
--- a/plan/test.ps Tue Nov 18 19:17:56 2008 +0000
+++ b/plan/test.ps Tue Nov 18 19:33:03 2008 +0000
@@ -410,3 +410,4 @@
end
restore
%%EOF
+
--- a/src/proto2/Vector.hh Tue Nov 18 19:17:56 2008 +0000
+++ b/src/proto2/Vector.hh Tue Nov 18 19:33:03 2008 +0000
@@ -1,47 +1,54 @@
#ifndef COOR_H
#define COOR_H
-//#define TYPE double
+#include <iostream>
-template <typename TYPE>
-class coor {
+template <typename T>
+class _Vector {
public:
- 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;
+ T x;
+ T y;
+
+ _Vector() : x(0), y(0){}
+ _Vector(T x, T y) : x(x), y(y) {}
+ _Vector(const _Vector& v) : x(v.x), y(v.y) {}
+
+ void operator=(const _Vector& v) {
+ this->x = v.x;
+ this->y = v.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);
+ _Vector operator+(const _Vector& v) const {
+ return _Vector(this->x+v.x, this->y+v.y);
}
- coor operator - (const coor& c) {
- return coor(x-c.x, y-c.y);
+ _Vector operator-(const _Vector& v) const {
+ return _Vector(this->x-v.x, this->y-v.y);
}
- void operator += (const coor& c) {
- x += c.x;
- y += c.y;
+ _Vector operator*(const T d) const {
+ return _Vector(this->x*d, this->y*d);
}
- coor operator * (const double d) {
- return coor(x*d, y*d);
+ _Vector operator/(const T d) const {
+ return _Vector(this->x/d, this->y/d);
+ }
+ void operator+=(const _Vector& v) {
+ this->x += v.x;
+ this->y += v.y;
}
-
+ void operator*=(const T f) {
+ this->x *= f;
+ this->y *= f;
+ }
};
template<typename T>
-bool operator== (const coor<T>& c1, const coor<T>& c2) {
- return ((c1.x == c2.x) && (c1.y == c2.y));
+bool operator==(const _Vector<T>& v1, const _Vector<T>& v2) {
+ return ((v1.x == v2.x) && (v1.y == v2.y));
}
+template<typename T>
+std::ostream& operator<<(std::ostream &s, _Vector<T> &v) {
+ return s<<"("<<v.x<<", "<<v.y<<")";
+}
+
+typedef _Vector<uint32_t> Vector;
+
#endif