X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgeometry%2Foperators.h;fp=src%2Fgeometry%2Foperators.h;h=7a8e7eab1b47b31f8b4a0defc1e9bc2f8a73a08a;hb=a2cf146565731e09f2e4d3159c19229abc33b143;hp=0000000000000000000000000000000000000000;hpb=d997e6743dfa0df245bc3f59ee97ecd63efb3c4f;p=l2e.git diff --git a/src/geometry/operators.h b/src/geometry/operators.h new file mode 100644 index 0000000..7a8e7ea --- /dev/null +++ b/src/geometry/operators.h @@ -0,0 +1,41 @@ +/* + * operators.h + * + * Created on: Aug 6, 2012 + * Author: holy + */ + +#ifndef GEOMETRY_OPERATORS_H_ +#define GEOMETRY_OPERATORS_H_ + +#include "Point.h" +#include "Vector.h" + +namespace geometry { + +template +inline Vector operator +(const Vector &lhs, const Vector &rhs) { + return Vector(lhs.X() + rhs.X(), lhs.Y() + rhs.Y()); +} +template +inline Point operator +(const Point &lhs, const Vector &rhs) { + return Point(lhs.X() + rhs.X(), lhs.Y() + rhs.Y()); +} + +template +inline Vector operator -(const Vector &lhs, const Vector &rhs) { + return Vector(lhs.X() - rhs.X(), lhs.Y() - rhs.Y()); +} +template +inline Point operator -(const Point &lhs, const Vector &rhs) { + return Point(lhs.X() - rhs.X(), lhs.Y() - rhs.Y()); +} + +template +inline Vector operator -(const Vector &v) { + return Vector(-v.X(), -v.Y()); +} + +} + +#endif /* GEOMETRY_OPERATORS_H_ */