wren
Vulkan-based game engine
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <ostream>
4
5#include "matrix.hpp"
6#include "vector.hpp"
7
8namespace wren::math {
9
10template <typename T, std::size_t N>
11auto operator<<(std::ostream& os, const Vec<T, N>& value) -> std::ostream& {
12 os << "(";
13 for (std::size_t i = 0; i < value.data.size(); i++) {
14 os << value.data.at(i);
15 if (i < value.data.size() - 1) os << ",";
16 }
17 os << ")";
18
19 return os;
20}
21
22template <typename T, std::size_t Rows, std::size_t Cols>
23auto operator<<(std::ostream& os, const Mat<T, Rows, Cols>& value)
24 -> std::ostream& {
25 os << "\n(";
26
27 for (std::size_t r = 0; r < Rows; ++r) {
28 for (std::size_t c = 0; c < Cols; ++c) {
29 os << value.at(c, r);
30 if (c < Cols - 1) os << ",";
31 }
32
33 if (r < Rows - 1) os << "\n";
34 }
35 os << ")";
36 return os;
37}
38
39} // namespace wren::math
Definition matrix.hpp:13
Definition geometry.hpp:8
auto operator<<(std::ostream &os, const Vec< T, N > &value) -> std::ostream &
Definition utils.hpp:11
Definition vector.hpp:9