aboutsummaryrefslogtreecommitdiff
path: root/src/engine/matrix.hpp
blob: c243eafb2980e8689a757a5fc1618a5e4232dfc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once

#include "engine/bounds.hpp"
#include "engine/vector2.hpp"

#include <vector>

/**
 * A Matrix.
 */
template <typename Element>
class Matrix
{
public:
	/**
	 * Creates a matrix.
	 *
	 * @param bounds The bounds of the matrix
	 */
	explicit Matrix(const Bounds &bounds);

	/**
	 * Fills the matrix with a element.
	 *
	 * @param element A element
	 */
	void fill(Element element);

	/**
	 * Prints the matrix.
	 */
	void print();

	/**
	 * Returns a element of the matrix.
	 *
	 * @param pos The position of a element
	 */
	Element get(Vector2 pos);

	/**
	 * Sets a element of the matrix.
	 *
	 * @param pos The position of a element
	 * @param element A new element
	 */
	void set(Vector2 pos, Element element);

	/**
	 * Returns the number of rows the matrix has.
	 */
	unsigned int rows();

	/**
	 * Returns the number of columns the matrix has.
	 */
	unsigned int columns();

private:
	std::vector<std::vector<Element>> _matrix;
	unsigned int _rows;
	unsigned int _columns;
};

#include "matrix.tpp"