From b918f21567716c4c4e381a5db307a05adc4b5479 Mon Sep 17 00:00:00 2001 From: "DrZiplok@gmail.com" Date: Wed, 8 Sep 2010 08:41:29 +0000 Subject: [PATCH] Replace the questionable rotation operation with a conventional transposition. git-svn-id: https://arducopter.googlecode.com/svn/trunk@442 f9c3cf11-9bcb-44bc-f272-b75c42450872 --- libraries/AP_Math/matrix3.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/libraries/AP_Math/matrix3.h b/libraries/AP_Math/matrix3.h index 23bf28ba5d..9197372130 100644 --- a/libraries/AP_Math/matrix3.h +++ b/libraries/AP_Math/matrix3.h @@ -13,6 +13,21 @@ * By Bill Perone (billperone@yahoo.com) */ +// +// 3x3 matrix implementation. +// +// Note that the matrix is organised in row-normal form (the same as +// applies to array indexing). +// +// In addition to the template, this header defines the following types: +// +// Matrix3i 3x3 matrix of signed integers +// Matrix3ui 3x3 matrix of unsigned integers +// Matrix3l 3x3 matrix of signed longs +// Matrix3ul 3x3 matrix of unsigned longs +// Matrix3f 3x3 matrix of signed floats +// + #ifndef MATRIX3_H #define MATRIX3_H @@ -85,7 +100,7 @@ public: c.x * v.z + c.y * v.z + c.z * v.z); } - // multiplication by another Matrix3 + // multiplication by another Matrix3 const Matrix3 operator *(const Matrix3 &m) const { Matrix3 temp = (Vector3(a.x * m.a.x + a.y * m.b.x + a.z * m.c.x, @@ -102,19 +117,18 @@ public: const Matrix3 operator *=(const Matrix3 &m) { return *this = this * m; } - // rotation (90 degrees left) - const Matrix3 rotated(void) + // transpose the matrix + const Matrix3 transposed(void) { - return Matrix3(Vector3(a.z, b.z, c.z), + return Matrix3(Vector3(a.x, b.x, c.x), Vector3(a.y, b.y, c.y), - Vector3(a.x, b.x, c.x)); + Vector3(a.z, b.z, c.z)); } - const Matrix3 rotate(void) - { return *this = rotated(); } + const Matrix3 transpose(void) + { return *this = transposed(); } }; -// macro to make creating the ctors for derived matrices easier #define MATRIX3_CTORS(name, type) \ /* trivial ctor */ \ name() {} \