diff options
Diffstat (limited to 'src/math.hpp')
-rw-r--r-- | src/math.hpp | 22 |
1 files changed, 21 insertions, 1 deletions
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<T, N> floor(void) + { + vec_t<T, N> 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 <typename U> @@ -243,6 +258,11 @@ public: return true; } + T dim(size_t i) const + { + return v[1][i] - v[0][i]; + } + friend rect_t<T, N> operator+(const rect_t<T, N> &a, const rect_t<T, N> &b) { rect_t r; @@ -257,7 +277,7 @@ public: friend std::ostream& operator<<(std::ostream& stream, rect_t<T, N> r) { - stream << "(" << r[0] << ", " << r[1] << ")"; + stream << "(" << r[0] << " x " << r[1] << ")"; return stream; } }; |