# HG changeset patch # User saiam # Date 1227036783 0 # Node ID 8ae9dd0ae3376c237de290e422f3b85df1ee9c15 # Parent b8b043ba0abde4a2aa0f1d36d27445bbb240a55f It compiles!!!! diff -r b8b043ba0abd -r 8ae9dd0ae337 plan/diagram.dot --- 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; diff -r b8b043ba0abd -r 8ae9dd0ae337 plan/test.ps --- 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 + diff -r b8b043ba0abd -r 8ae9dd0ae337 src/proto2/Vector.hh --- 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 -template -class coor { +template +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 -bool operator== (const coor& c1, const coor& c2) { - return ((c1.x == c2.x) && (c1.y == c2.y)); +bool operator==(const _Vector& v1, const _Vector& v2) { + return ((v1.x == v2.x) && (v1.y == v2.y)); } +template +std::ostream& operator<<(std::ostream &s, _Vector &v) { + return s<<"("< Vector; + #endif