From 20b189455545db5688ed4f14d2966380137ee2db Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 21 Oct 2017 11:20:34 +0200 Subject: Start working on path finding. --- src/math.hpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/math.hpp') diff --git a/src/math.hpp b/src/math.hpp index c07b7d0..f3b049b 100644 --- a/src/math.hpp +++ b/src/math.hpp @@ -178,6 +178,21 @@ public: return v; } + vec_t floor(void) + { + vec_t r; + + for (size_t i = 0; i < N; i++) + r[i] = std::floor(v[i]); + + return r; + } + + T len(void) + { + return std::sqrt(*this * *this); + } + // Compatibility with SFML template @@ -243,6 +258,11 @@ public: return true; } + T dim(size_t i) const + { + return v[1][i] - v[0][i]; + } + friend rect_t operator+(const rect_t &a, const rect_t &b) { rect_t r; @@ -257,7 +277,7 @@ public: friend std::ostream& operator<<(std::ostream& stream, rect_t r) { - stream << "(" << r[0] << ", " << r[1] << ")"; + stream << "(" << r[0] << " x " << r[1] << ")"; return stream; } }; -- cgit