ScummVM API documentation
Matrix4x4.h
1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21 
22 #ifndef WATCHMAKER_MATRIX4X4_H
23 #define WATCHMAKER_MATRIX4X4_H
24 
25 #include "common/scummsys.h"
26 #include "common/textconsole.h"
27 
28 namespace Watchmaker {
29 
30 struct Matrix4x4 {
31  float data[16] = {};
32 
33  void setIdentity() {
34  setValue(1, 1, 1.0f);
35  setValue(2, 2, 1.0f);
36  setValue(3, 3, 1.0f);
37  setValue(4, 4, 1.0f);
38  }
39 
40  void setValue(int row, int col, float value) {
41  data[(col - 1) * 4 + (row - 1)] = value;
42  }
43  float getValue(int row, int col) const {
44  return data[(col - 1) * 4 + (row - 1)];
45  }
46  void print() const {
47  for (int row = 1; row <= 4; row++) {
48  for (int col = 1; col <= 4; col++) {
49  warning("%f ", getValue(row, col));
50  }
51  warning(" ");
52  }
53  }
54  bool operator==(const Matrix4x4 &rhs) const {
55  for (int row = 1; row <= 4; row++) {
56  for (int col = 1; col <= 4; col++) {
57  if (getValue(row, col) != rhs.getValue(row, col)) {
58  return false;
59  }
60  }
61  }
62  return true;
63  }
64 };
65 
66 
67 } // End of namespace Watchmaker
68 
69 #endif // WATCHMAKER_MATRIX4X4_H
Definition: 2d_stuff.h:30
void warning(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: Matrix4x4.h:30