mercator 0.4.0
A terrain generation library for the Worldforge system.
Matrix.h
1// This file may be redistributed and modified only under the terms of
2// the GNU General Public License (See COPYING for details).
3// Copyright (C) 2003 Alistair Riddoch
4
5#ifndef MERCATOR_MATRIX_H
6#define MERCATOR_MATRIX_H
7
8namespace Mercator {
9
13template <unsigned int COLS, unsigned int ROWS, typename FloatType = float>
14class Matrix {
15 private:
17 FloatType m_data[COLS * ROWS];
18 public:
20 Matrix() = default;
21
23 FloatType & operator()(unsigned int col, unsigned int row) {
24 return m_data[row * COLS + col];
25 }
26
28 const FloatType & operator()(unsigned int col, unsigned int row) const {
29 return m_data[row * COLS + col];
30 }
31
33 FloatType & operator[](unsigned int idx) {
34 return m_data[idx];
35 }
36};
37
38}
39
40#endif // MERCATOR_MATRIX_H
A fixed sized array of objects.
Definition: Matrix.h:14
Matrix()=default
Constructor for the Matrix.
FloatType & operator()(unsigned int col, unsigned int row)
Accessor for modifying the array.
Definition: Matrix.h:23
FloatType & operator[](unsigned int idx)
Accessor for accessing the array as one dimensional.
Definition: Matrix.h:33
const FloatType & operator()(unsigned int col, unsigned int row) const
Accessor for the array.
Definition: Matrix.h:28