From 8e92b0c5aa0cc57e8729069dad4cb635845f51d8 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Mon, 24 May 2010 03:12:17 +0200 Subject: Added Matrix-class. --- engine/matrix.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 engine/matrix.cpp (limited to 'engine/matrix.cpp') diff --git a/engine/matrix.cpp b/engine/matrix.cpp new file mode 100644 index 0000000..96c539c --- /dev/null +++ b/engine/matrix.cpp @@ -0,0 +1,29 @@ +#include "matrix.h" + +#include + +Matrix2::Matrix2() { + m[0][0] = m[0][1] = + m[1][0] = m[1][1] = 0; +} + +Matrix2::Matrix2(float m00, float m01, float m10, float m11) { + m[0][0] = m00; + m[0][1] = m01; + m[1][0] = m10; + m[1][1] = m11; +} + +Vector2 Matrix2::operator*(const Vector2& v) { + return Vector2( + m[0][0] * v.x + m[0][1] * v.y, + m[1][0] * v.x + m[1][1] * v.y); +} + +Matrix2 rotation_matrix(float rot) { + float s = sinf(rot); + float c = cosf(rot); + return Matrix2( + c, -s, + s, c); +} \ No newline at end of file -- cgit v1.2.3