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