4 * Created on: Aug 6, 2012
8 #ifndef GEOMETRY_OPERATORS_H_
9 #define GEOMETRY_OPERATORS_H_
19 inline Vector<T> operator +(const Vector<T> &lhs, const Vector<T> &rhs) {
20 return Vector<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
23 inline Point<T> operator +(const Point<T> &lhs, const Vector<T> &rhs) {
24 return Point<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
28 inline Vector<T> &operator +=(Vector<T> &lhs, const Vector<T> &rhs) {
33 inline Point<T> &operator +=(Point<T> &lhs, const Vector<T> &rhs) {
39 inline Vector<T> operator -(const Vector<T> &lhs, const Vector<T> &rhs) {
40 return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
43 inline Point<T> operator -(const Point<T> &lhs, const Vector<T> &rhs) {
44 return Point<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
48 inline Vector<T> operator -(const Vector<T> &v) {
49 return Vector<T>(-v.X(), -v.Y());
53 inline std::ostream &operator <<(std::ostream &out, const Point<T> &p) {
54 out << '(' << p.X() << ", " << p.Y() << ')';
58 inline std::ostream &operator <<(std::ostream &out, const Vector<T> &v) {
59 out << '<' << v.X() << ", " << v.Y() << '>';
65 #endif /* GEOMETRY_OPERATORS_H_ */