add MatrixCross

Committer:
Yo_Robot
Date:
Sun Oct 30 04:41:00 2011 +0000
Revision:
2:d487bb616ec1
Parent:
1:c74cdf14aea2
Child:
3:48754fe86e08
Kinematic and Dot functions version 0.9

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Yo_Robot 2:d487bb616ec1 1 /**
Yo_Robot 2:d487bb616ec1 2 * @file MatrixMath.h
Yo_Robot 2:d487bb616ec1 3 * @author Ernesto Palacios
Yo_Robot 2:d487bb616ec1 4 *
Yo_Robot 2:d487bb616ec1 5 * Created on 15 de septiembre de 2011, 09:44 AM.
Yo_Robot 2:d487bb616ec1 6 *
Yo_Robot 2:d487bb616ec1 7 * Develop Under GPL v3.0 License
Yo_Robot 2:d487bb616ec1 8 * http://www.gnu.org/licenses/gpl-3.0.html
Yo_Robot 2:d487bb616ec1 9 *
Yo_Robot 2:d487bb616ec1 10 */
Yo_Robot 2:d487bb616ec1 11
Yo_Robot 2:d487bb616ec1 12 #ifndef MATRIXMATH_H
Yo_Robot 2:d487bb616ec1 13 #define MATRIXMATH_H
Yo_Robot 2:d487bb616ec1 14
Yo_Robot 2:d487bb616ec1 15 #include "mbed.h"
Yo_Robot 2:d487bb616ec1 16 #include "Matrix.h"
Yo_Robot 2:d487bb616ec1 17
Yo_Robot 2:d487bb616ec1 18
Yo_Robot 2:d487bb616ec1 19 /**
Yo_Robot 2:d487bb616ec1 20 * @brief This class provides STATIC methods to preform operations over
Yo_Robot 2:d487bb616ec1 21 * Matrix Objects
Yo_Robot 2:d487bb616ec1 22 * version 0.8.
Yo_Robot 2:d487bb616ec1 23 *
Yo_Robot 2:d487bb616ec1 24 * Methods will be added as neccesary.
Yo_Robot 2:d487bb616ec1 25 *
Yo_Robot 2:d487bb616ec1 26 */
Yo_Robot 2:d487bb616ec1 27 class MatrixMath{
Yo_Robot 2:d487bb616ec1 28 public:
Yo_Robot 2:d487bb616ec1 29
Yo_Robot 2:d487bb616ec1 30
Yo_Robot 2:d487bb616ec1 31 /**@brief
Yo_Robot 2:d487bb616ec1 32 * Transposes Matrix, return new Object.
Yo_Robot 2:d487bb616ec1 33 * @param Mat matrix to calculate
Yo_Robot 2:d487bb616ec1 34 * @return the determinant
Yo_Robot 2:d487bb616ec1 35 */
Yo_Robot 2:d487bb616ec1 36 static Matrix Transpose( const Matrix& Mat );
Yo_Robot 2:d487bb616ec1 37
Yo_Robot 2:d487bb616ec1 38
Yo_Robot 2:d487bb616ec1 39 /**@brief
Yo_Robot 2:d487bb616ec1 40 * Calculate the inverse of a nxn Matrix BUT check first if the determinant
Yo_Robot 2:d487bb616ec1 41 * is != 0. Same matrix will be return if Det( Mat ) == 0.
Yo_Robot 2:d487bb616ec1 42 * @param Mat matrix to calcute inverse.
Yo_Robot 2:d487bb616ec1 43 * @return Matrix Inverse
Yo_Robot 2:d487bb616ec1 44 */
Yo_Robot 2:d487bb616ec1 45 static Matrix Inv( const Matrix& Mat );
Yo_Robot 2:d487bb616ec1 46
Yo_Robot 2:d487bb616ec1 47
Yo_Robot 2:d487bb616ec1 48 /**@brief
Yo_Robot 2:d487bb616ec1 49 * Creates an identity Matrix, n x n.
Yo_Robot 2:d487bb616ec1 50 * @param Rows Number of Rowns and Columns
Yo_Robot 2:d487bb616ec1 51 * @return Identity Matrix of dimensions Rows x Rows
Yo_Robot 2:d487bb616ec1 52 */
Yo_Robot 2:d487bb616ec1 53 static Matrix Eye( int Rows );
Yo_Robot 2:d487bb616ec1 54
Yo_Robot 2:d487bb616ec1 55 /**@brief
Yo_Robot 2:d487bb616ec1 56 * Returns the dot Product of any two same leght vectors.
Yo_Robot 2:d487bb616ec1 57 * In this case a vector is defined as a [1,n] Matrix.
Yo_Robot 2:d487bb616ec1 58 * @param leftM First Vector
Yo_Robot 2:d487bb616ec1 59 * @param rightM Second Vector
Yo_Robot 2:d487bb616ec1 60 * @return Dot Product or Scalar Product.
Yo_Robot 2:d487bb616ec1 61 */
Yo_Robot 2:d487bb616ec1 62 static float dot( const Matrix& leftM, const Matrix& rightM );
Yo_Robot 2:d487bb616ec1 63
Yo_Robot 2:d487bb616ec1 64 /**@brief Calculates the determinant of a Matrix.
Yo_Robot 2:d487bb616ec1 65 * @param Mat matrix to calculate.
Yo_Robot 2:d487bb616ec1 66 * @return the determinant.
Yo_Robot 2:d487bb616ec1 67 */
Yo_Robot 2:d487bb616ec1 68 static float det( const Matrix& Mat );
Yo_Robot 2:d487bb616ec1 69
Yo_Robot 2:d487bb616ec1 70
Yo_Robot 2:d487bb616ec1 71 //==== For Kinematics ====//
Yo_Robot 2:d487bb616ec1 72
Yo_Robot 2:d487bb616ec1 73 /**@brief
Yo_Robot 2:d487bb616ec1 74 * Calculates the Rotation Matrix Transform along 'x' axis in radians.
Yo_Robot 2:d487bb616ec1 75 * @param radians rotation angle.
Yo_Robot 2:d487bb616ec1 76 * @return Rotation Matrix[4,4] along 'x' axis.
Yo_Robot 2:d487bb616ec1 77 */
Yo_Robot 2:d487bb616ec1 78 static Matrix RotX( float radians );
Yo_Robot 2:d487bb616ec1 79
Yo_Robot 2:d487bb616ec1 80
Yo_Robot 2:d487bb616ec1 81 /**@brief
Yo_Robot 2:d487bb616ec1 82 * Calculates the Rotation Matrix Transform along 'y' axis in radians.
Yo_Robot 2:d487bb616ec1 83 * @param radians rotation angle.
Yo_Robot 2:d487bb616ec1 84 * @return Rotation Matrix[4,4] along 'y' axis.
Yo_Robot 2:d487bb616ec1 85 */
Yo_Robot 2:d487bb616ec1 86 static Matrix RotY( float radians );
Yo_Robot 2:d487bb616ec1 87
Yo_Robot 2:d487bb616ec1 88
Yo_Robot 2:d487bb616ec1 89 /**@brief
Yo_Robot 2:d487bb616ec1 90 * Calculates the Rotation Matrix Transform along 'y' axis in radians.
Yo_Robot 2:d487bb616ec1 91 * @param radians rotation angle.
Yo_Robot 2:d487bb616ec1 92 * @return Rotation Matrix[4,4] along 'y' axis.
Yo_Robot 2:d487bb616ec1 93 */
Yo_Robot 2:d487bb616ec1 94 static Matrix RotZ( float radians );
Yo_Robot 2:d487bb616ec1 95
Yo_Robot 2:d487bb616ec1 96 /**@brief
Yo_Robot 2:d487bb616ec1 97 * Calculates the Translation Matrix to coordenates, (x' y' z')
Yo_Robot 2:d487bb616ec1 98 * @param x axis translation
Yo_Robot 2:d487bb616ec1 99 * @param y axis translation
Yo_Robot 2:d487bb616ec1 100 * @param z axis translation
Yo_Robot 2:d487bb616ec1 101 * @return Translation Matrix[4,4] x'y'z'.
Yo_Robot 2:d487bb616ec1 102 */
Yo_Robot 2:d487bb616ec1 103 static Matrix Transl( float x, float y, float z );
Yo_Robot 2:d487bb616ec1 104
Yo_Robot 2:d487bb616ec1 105 private:
Yo_Robot 2:d487bb616ec1 106
Yo_Robot 2:d487bb616ec1 107 /**@brief
Yo_Robot 2:d487bb616ec1 108 * Calculates the Determinant of a 3x3 Matrix
Yo_Robot 2:d487bb616ec1 109 * @param Mat Already made sure is a 3 by 3
Yo_Robot 2:d487bb616ec1 110 * @return Float, determinant.
Yo_Robot 2:d487bb616ec1 111 */
Yo_Robot 2:d487bb616ec1 112 float Det3x3( const Matrix& Mat );
Yo_Robot 2:d487bb616ec1 113
Yo_Robot 2:d487bb616ec1 114 };
Yo_Robot 2:d487bb616ec1 115
Yo_Robot 2:d487bb616ec1 116 #endif /* MATRIXMATH_H */