]> git.localhorst.tv Git - l2e.git/blobdiff - src/geometry/operators.h
extracted damage calculation once more
[l2e.git] / src / geometry / operators.h
index 7a8e7eab1b47b31f8b4a0defc1e9bc2f8a73a08a..295daa1a6b4fc2471eb2c88007b3ff3eb9e39af7 100644 (file)
@@ -11,6 +11,8 @@
 #include "Point.h"
 #include "Vector.h"
 
+#include <ostream>
+
 namespace geometry {
 
 template<class T>
@@ -22,6 +24,15 @@ inline Point<T> operator +(const Point<T> &lhs, const Vector<T> &rhs) {
        return Point<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
 }
 
+template<class T>
+inline Vector<T> &operator +=(Vector<T> &lhs, const Vector<T> &rhs) {
+       return lhs = lhs + rhs;
+}
+template<class T>
+inline Point<T> &operator +=(Point<T> &lhs, const Vector<T> &rhs) {
+       return lhs = lhs + rhs;
+}
+
 template<class T>
 inline Vector<T> operator -(const Vector<T> &lhs, const Vector<T> &rhs) {
        return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
@@ -31,11 +42,31 @@ inline Point<T> operator -(const Point<T> &lhs, const Vector<T> &rhs) {
        return Point<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
 }
 
+template<class T>
+inline Vector<T> &operator -=(Vector<T> &lhs, const Vector<T> &rhs) {
+       return lhs = lhs - rhs;
+}
+template<class T>
+inline Point<T> &operator -=(Point<T> &lhs, const Vector<T> &rhs) {
+       return lhs = lhs - rhs;
+}
+
 template<class T>
 inline Vector<T> operator -(const Vector<T> &v) {
        return Vector<T>(-v.X(), -v.Y());
 }
 
+template<class T>
+inline std::ostream &operator <<(std::ostream &out, const Point<T> &p) {
+       out << '(' << p.X() << ", " << p.Y() << ')';
+       return out;
+}
+template<class T>
+inline std::ostream &operator <<(std::ostream &out, const Vector<T> &v) {
+       out << '<' << v.X() << ", " << v.Y() << '>';
+       return out;
+}
+
 }
 
 #endif /* GEOMETRY_OPERATORS_H_ */