This class provides with operations for Matrix Objects
Dependents: Matrix_class Wizardsneverdie mbed_multiplex_matrix Kinematics_Project_G5 ... more
MatrixMath.h@5:93948a9bbde2, 2011-10-30 (annotated)
- Committer:
- Yo_Robot
- Date:
- Sun Oct 30 19:21:30 2011 +0000
- Revision:
- 5:93948a9bbde2
- Parent:
- 3:48754fe86e08
- Child:
- 6:aa5e94cddb3f
Version 0.9 Simple Kinematic Operations. View Log.c on Matrix Class for details.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Yo_Robot | 3:48754fe86e08 | 1 | /** |
Yo_Robot | 5:93948a9bbde2 | 2 | * @brief Version 0.9 |
Yo_Robot | 3:48754fe86e08 | 3 | * @file MatrixMath.h |
Yo_Robot | 3:48754fe86e08 | 4 | * @author Ernesto Palacios |
Yo_Robot | 3:48754fe86e08 | 5 | * |
Yo_Robot | 3:48754fe86e08 | 6 | * Created on 15 de septiembre de 2011, 09:44 AM. |
Yo_Robot | 3:48754fe86e08 | 7 | * |
Yo_Robot | 5:93948a9bbde2 | 8 | * Develop Under GPL v3.0 License |
Yo_Robot | 5:93948a9bbde2 | 9 | * http://www.gnu.org/licenses/gpl-3.0.html |
Yo_Robot | 3:48754fe86e08 | 10 | * |
Yo_Robot | 3:48754fe86e08 | 11 | */ |
Yo_Robot | 3:48754fe86e08 | 12 | |
Yo_Robot | 5:93948a9bbde2 | 13 | #ifndef MATRIXMATH_H |
Yo_Robot | 5:93948a9bbde2 | 14 | #define MATRIXMATH_H |
Yo_Robot | 3:48754fe86e08 | 15 | |
Yo_Robot | 3:48754fe86e08 | 16 | #include "mbed.h" |
Yo_Robot | 3:48754fe86e08 | 17 | #include "Matrix.h" |
Yo_Robot | 3:48754fe86e08 | 18 | |
Yo_Robot | 3:48754fe86e08 | 19 | |
Yo_Robot | 3:48754fe86e08 | 20 | /** |
Yo_Robot | 5:93948a9bbde2 | 21 | * @brief This class provides STATIC methods to perform operations |
Yo_Robot | 5:93948a9bbde2 | 22 | * over Matrix Objects, version 0.9. |
Yo_Robot | 3:48754fe86e08 | 23 | */ |
Yo_Robot | 3:48754fe86e08 | 24 | class MatrixMath{ |
Yo_Robot | 3:48754fe86e08 | 25 | public: |
Yo_Robot | 3:48754fe86e08 | 26 | |
Yo_Robot | 3:48754fe86e08 | 27 | |
Yo_Robot | 3:48754fe86e08 | 28 | /**@brief |
Yo_Robot | 3:48754fe86e08 | 29 | * Transposes Matrix, return new Object. |
Yo_Robot | 3:48754fe86e08 | 30 | * @param Mat matrix to calculate |
Yo_Robot | 5:93948a9bbde2 | 31 | * @return Transposed Matrix |
Yo_Robot | 3:48754fe86e08 | 32 | */ |
Yo_Robot | 3:48754fe86e08 | 33 | static Matrix Transpose( const Matrix& Mat ); |
Yo_Robot | 3:48754fe86e08 | 34 | |
Yo_Robot | 3:48754fe86e08 | 35 | |
Yo_Robot | 3:48754fe86e08 | 36 | /**@brief |
Yo_Robot | 5:93948a9bbde2 | 37 | * Calculate the inverse of a [n,n] Matrix BUT you check first if |
Yo_Robot | 5:93948a9bbde2 | 38 | * the determinant is != 0, Same matrix will be return if Det( Mat ) == 0. |
Yo_Robot | 3:48754fe86e08 | 39 | * @param Mat matrix to calcute inverse. |
Yo_Robot | 3:48754fe86e08 | 40 | * @return Matrix Inverse |
Yo_Robot | 3:48754fe86e08 | 41 | */ |
Yo_Robot | 3:48754fe86e08 | 42 | static Matrix Inv( const Matrix& Mat ); |
Yo_Robot | 3:48754fe86e08 | 43 | |
Yo_Robot | 3:48754fe86e08 | 44 | |
Yo_Robot | 3:48754fe86e08 | 45 | /**@brief |
Yo_Robot | 5:93948a9bbde2 | 46 | * Creates an identity [n,n] Matrix |
Yo_Robot | 3:48754fe86e08 | 47 | * @param Rows Number of Rowns and Columns |
Yo_Robot | 5:93948a9bbde2 | 48 | * @return Identity Matrix of dimensions [Rows,Rows] |
Yo_Robot | 3:48754fe86e08 | 49 | */ |
Yo_Robot | 3:48754fe86e08 | 50 | static Matrix Eye( int Rows ); |
Yo_Robot | 5:93948a9bbde2 | 51 | |
Yo_Robot | 3:48754fe86e08 | 52 | |
Yo_Robot | 3:48754fe86e08 | 53 | /**@brief |
Yo_Robot | 3:48754fe86e08 | 54 | * Returns the dot Product of any two same leght vectors. |
Yo_Robot | 5:93948a9bbde2 | 55 | * In this case a vector is defined as a [1,n] or [n,1] Matrix. |
Yo_Robot | 5:93948a9bbde2 | 56 | * Very Flexible Function. |
Yo_Robot | 3:48754fe86e08 | 57 | * @param leftM First Vector |
Yo_Robot | 3:48754fe86e08 | 58 | * @param rightM Second Vector |
Yo_Robot | 3:48754fe86e08 | 59 | * @return Dot Product or Scalar Product. |
Yo_Robot | 3:48754fe86e08 | 60 | */ |
Yo_Robot | 3:48754fe86e08 | 61 | static float dot( const Matrix& leftM, const Matrix& rightM ); |
Yo_Robot | 5:93948a9bbde2 | 62 | |
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 | 5:93948a9bbde2 | 90 | * Calculates the Rotation Matrix Transform along 'z' axis in radians. |
Yo_Robot | 3:48754fe86e08 | 91 | * @param radians rotation angle. |
Yo_Robot | 5:93948a9bbde2 | 92 | * @return Rotation Matrix[4,4] along 'z' 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 | 5:93948a9bbde2 | 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 */ |