Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-04-27 13:08:12 +0000
committerStijn Buys <ingar@osirion.org>2008-04-27 13:08:12 +0000
commita4b36e6d1e20b5036d1ed7cf9f61a48dbbf77812 (patch)
tree7efd0048fd8c10b1f04d427c78e3ac8da402f059 /src/math/matrix4f.cc
parentfe95954f9d17c9dade1827fe5d4cf8cffffddbce (diff)
3D flight
Diffstat (limited to 'src/math/matrix4f.cc')
-rw-r--r--src/math/matrix4f.cc79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/math/matrix4f.cc b/src/math/matrix4f.cc
new file mode 100644
index 0000000..d73b12e
--- /dev/null
+++ b/src/math/matrix4f.cc
@@ -0,0 +1,79 @@
+/*
+ math/matrix4f.cc
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+// project headers
+#include "math/matrix4f.h"
+
+// C++ headers
+#include <cmath>
+
+namespace math
+{
+
+Matrix4f::Matrix4f()
+{
+ clear();
+}
+
+Matrix4f::Matrix4f(const Matrix4f & other)
+{
+ assign(other);
+}
+
+Matrix4f::Matrix4f(const Axis & axis)
+{
+ assign(axis);
+}
+
+void Matrix4f::clear()
+{
+ memset(matrix, 0, sizeof(matrix));
+}
+
+void Matrix4f::unity()
+{
+ memset(matrix, 0, sizeof(matrix));
+ for (int i=0; i <4; i++)
+ matrix[i][i] = 1;
+}
+
+void Matrix4f::assign(const Matrix4f & other)
+{
+ memcpy(matrix, other.matrix, sizeof(matrix));
+}
+
+void Matrix4f::assign(const Axis & axis)
+{
+ memset(matrix, 0, sizeof(matrix));
+ for (int i=0; i < 3; i++) {
+ memcpy(&matrix[i][0], axis[i].ptr(), sizeof(float) * 3);
+ }
+ matrix[3][3] = 1;
+}
+
+Matrix4f & Matrix4f::operator=(const Matrix4f &other)
+{
+ assign(other);
+ return(*this);
+}
+
+Matrix4f & Matrix4f::operator=(const Axis & axis)
+{
+ assign(axis);
+ return(*this);
+}
+
+Matrix4f const Matrix4f::transpose()
+{
+ Matrix4f t;
+
+ for (size_t i = 0; i < 4; i++)
+ for (size_t j = 0; j < 4; j++)
+ t.matrix[j][i] = matrix[i][j];
+ return t;
+}
+
+}