src/sdl \
src \
src/graphics \
-src/geometry \
src/battle \
src/app \
+src/geometry \
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
-CPP_SRCS += \
-../src/geometry/Point.cpp
-
-OBJS += \
-./src/geometry/Point.o
-
-CPP_DEPS += \
-./src/geometry/Point.d
-
# Each subdirectory must supply rules for building sources it contributes
-src/geometry/%.o: ../src/geometry/%.cpp
- @echo 'Building file: $<'
- @echo 'Invoking: GCC C++ Compiler'
- g++ -I/usr/include/SDL -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
- @echo 'Finished building: $<'
- @echo ' '
-
src/sdl \
src \
src/graphics \
-src/geometry \
src/battle \
src/app \
+src/geometry \
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
-CPP_SRCS += \
-../src/geometry/Point.cpp
-
-OBJS += \
-./src/geometry/Point.o
-
-CPP_DEPS += \
-./src/geometry/Point.d
-
# Each subdirectory must supply rules for building sources it contributes
-src/geometry/%.o: ../src/geometry/%.cpp
- @echo 'Building file: $<'
- @echo 'Invoking: GCC C++ Compiler'
- g++ -I/usr/include/SDL -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
- @echo 'Finished building: $<'
- @echo ' '
-
+++ /dev/null
-/*
- * Point.cpp
- *
- * Created on: Aug 5, 2012
- * Author: holy
- */
-
-#include "Point.h"
-
-namespace geometry {
-
-} /* namespace geometry */
--- /dev/null
+/*
+ * Vector.h
+ *
+ * Created on: Aug 6, 2012
+ * Author: holy
+ */
+
+#ifndef GEOMETRY_VECTOR_H_
+#define GEOMETRY_VECTOR_H_
+
+namespace geometry {
+
+template<class Scalar>
+class Vector {
+
+public:
+ Vector() : x(0), y(0) { }
+ Vector(Scalar x, Scalar y) : x(x), y(y) { }
+ template<class T>
+ Vector(const Vector<T> &other) : x(other.X()), y(other.Y()) { };
+ template<class T>
+ Vector(T x, T y) : x(x), y(y) { }
+
+public:
+ Scalar X() const { return x; }
+ Scalar Y() const { return y; }
+
+private:
+ Scalar x, y;
+
+};
+
+}
+
+#endif /* GEOMETRY_VECTOR_H_ */
--- /dev/null
+/*
+ * 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<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());
+}
+template<class T>
+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 -(const Vector<T> &lhs, const Vector<T> &rhs) {
+ return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
+}
+template<class T>
+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 -(const Vector<T> &v) {
+ return Vector<T>(-v.X(), -v.Y());
+}
+
+}
+
+#endif /* GEOMETRY_OPERATORS_H_ */