HAPSRG / MatrixMath_2

Dependencies:   Matrix

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MatrixMath.h Source File

MatrixMath.h

Go to the documentation of this file.
00001 /**
00002  * @brief  Version 0.9
00003  * @file   MatrixMath.h
00004  * @author Ernesto Palacios
00005  *
00006  * Created on 15 de septiembre de 2011, 09:44 AM.
00007  *
00008  * Develop Under  GPL v3.0 License
00009  * http://www.gnu.org/licenses/gpl-3.0.html
00010  *
00011  */
00012 
00013 #ifndef  MATRIXMATH_H
00014 #define  MATRIXMATH_H
00015 
00016 #include "mbed.h"
00017 #include "Matrix.h"
00018 #include "Vector3.hpp"
00019 
00020 /**
00021  * @brief This class provides STATIC methods to perform operations 
00022  *        over Matrix Objects, version 0.9.
00023  */
00024 class MatrixMath{
00025 public:
00026 
00027 
00028     /**@brief
00029      * Transposes Matrix, return new Object.
00030      * @param Mat matrix to calculate
00031      * @return Transposed Matrix
00032      */
00033     static Matrix Transpose( const Matrix& Mat );
00034 
00035 
00036     /**@brief
00037      * Calculate the inverse of a [n,n] Matrix BUT you check first if 
00038      * the determinant is != 0, Same matrix will be return if Det( Mat ) == 0.
00039      * @param Mat matrix to calcute inverse.
00040      * @return Matrix Inverse
00041      */
00042      
00043     static Matrix Matrixcross(const float px, const float py, const float pz);
00044     /**@brief
00045      * 外積を計算するためのMatrixを計算する
00046      */
00047     
00048     static Matrix Vector2mat(const Vector3 vec);
00049     /**@brief
00050      * 外積を計算するためのMatrixを計算する
00051      */
00052     
00053     static Matrix Inv( const Matrix& Mat );
00054 
00055 
00056     /**@brief
00057      * Creates an identity [n,n] Matrix
00058      * @param Rows Number of Rowns and Columns
00059      * @return Identity Matrix of dimensions [Rows,Rows]
00060      */
00061     static Matrix Eye( int Rows );
00062     
00063 
00064     /**@brief
00065      * Returns the dot Product of any two same leght vectors.
00066      * In this case a vector is defined as a [1,n] or [n,1] Matrix.
00067      * Very Flexible Function.
00068      * @param leftM First Vector
00069      * @param rightM Second Vector
00070      * @return Dot Product or Scalar Product.
00071      */    
00072     static float dot( const Matrix& leftM, const Matrix& rightM );
00073     
00074 
00075     /**@brief Calculates the determinant of a Matrix.
00076      * @param Mat matrix to calculate.
00077      * @return the determinant.
00078      */
00079     static float det( const Matrix& Mat );
00080 
00081     /**@brief Calculates Kronecker product of two Matrix.
00082      * Kronecker product is an operation on two matrices of arbitrary
00083      * size resulting in a block matrix. If A is an m × n matrix 
00084      * and B is a p × q matrix, then the Kronecker product A ⊗ B is 
00085      * the pm × qn block matrix:
00086      *         -                    -
00087      *         | a_11 B ... a_1n B  |
00088      * A ⊗ B = | ...    ...    ...  |
00089      *         | a_m1 B ... a_mn B  |
00090      *         -                    -
00091      * @param Mat_A Matrix m × n 
00092      * @param Mat_B Matrix p × q
00093      * @return Kron Matrix pm × qn.
00094      */
00095     static Matrix kron(const Matrix& Mat_A, const Matrix& Mat_B);
00096 
00097 
00098     //====  For Kinematics ====//
00099 
00100     /**@brief
00101      * Calculates the Rotation Matrix Transform along 'x' axis in radians.
00102      * @param radians rotation angle.
00103      * @return Rotation Matrix[4,4] along 'x' axis.
00104      */
00105     static Matrix RotX( float radians );
00106 
00107 
00108     /**@brief
00109      * Calculates the Rotation Matrix Transform along 'y' axis in radians.
00110      * @param radians rotation angle.
00111      * @return Rotation Matrix[4,4] along 'y' axis.
00112      */
00113     static Matrix RotY( float radians );
00114 
00115 
00116     /**@brief
00117      * Calculates the Rotation Matrix Transform along 'z' axis in radians.
00118      * @param radians rotation angle.
00119      * @return Rotation Matrix[4,4] along 'z' axis.
00120      */
00121     static Matrix RotZ( float radians );
00122 
00123     /**@brief
00124      * Calculates the Translation Matrix to coordenates (x' y' z').
00125      * @param x axis translation
00126      * @param y axis translation
00127      * @param z axis translation
00128      * @return Translation Matrix[4,4] x'y'z'.
00129      */
00130     static Matrix Transl( float x, float y, float z );
00131 
00132 private:
00133 
00134     /**@brief
00135      * Calculates the Determinant of a 3x3 Matrix
00136      * @param Mat Already made sure is a 3 by 3
00137      * @return Float, determinant.
00138      */
00139     float Det3x3( const Matrix& Mat );
00140 
00141 };
00142 
00143 #endif    /* MATRIXMATH_H */