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) {
29 return lhs = lhs + rhs;
32 inline Point<T> &operator +=(Point<T> &lhs, const Vector<T> &rhs) {
33 return lhs = lhs + rhs;
37 inline Vector<T> operator -(const Vector<T> &lhs, const Vector<T> &rhs) {
38 return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
41 inline Point<T> operator -(const Point<T> &lhs, const Vector<T> &rhs) {
42 return Point<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
46 inline Vector<T> &operator -=(Vector<T> &lhs, const Vector<T> &rhs) {
47 return lhs = lhs - rhs;
50 inline Point<T> &operator -=(Point<T> &lhs, const Vector<T> &rhs) {
51 return lhs = lhs - rhs;
55 inline Vector<T> operator -(const Vector<T> &v) {
56 return Vector<T>(-v.X(), -v.Y());
60 inline std::ostream &operator <<(std::ostream &out, const Point<T> &p) {
61 out << '(' << p.X() << ", " << p.Y() << ')';
65 inline std::ostream &operator <<(std::ostream &out, const Vector<T> &v) {
66 out << '<' << v.X() << ", " << v.Y() << '>';
72 #endif /* GEOMETRY_OPERATORS_H_ */