Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MatrixMath.h
- Committer:
- NaotoMorita
- Date:
- 2021-08-10
- Revision:
- 7:b22d56ac37aa
- Parent:
- 6:aa5e94cddb3f
File content as of revision 7:b22d56ac37aa:
/**
* @brief Version 0.9
* @file MatrixMath.h
* @author Ernesto Palacios
*
* Created on 15 de septiembre de 2011, 09:44 AM.
*
* Develop Under GPL v3.0 License
* http://www.gnu.org/licenses/gpl-3.0.html
*
*/
#ifndef MATRIXMATH_H
#define MATRIXMATH_H
#include "mbed.h"
#include "Matrix.h"
#include "Vector3.hpp"
/**
* @brief This class provides STATIC methods to perform operations
* over Matrix Objects, version 0.9.
*/
class MatrixMath{
public:
/**@brief
* Transposes Matrix, return new Object.
* @param Mat matrix to calculate
* @return Transposed Matrix
*/
static Matrix Transpose( const Matrix& Mat );
/**@brief
* Calculate the inverse of a [n,n] Matrix BUT you check first if
* the determinant is != 0, Same matrix will be return if Det( Mat ) == 0.
* @param Mat matrix to calcute inverse.
* @return Matrix Inverse
*/
static Matrix Matrixcross(const float px, const float py, const float pz);
/**@brief
* 外積を計算するためのMatrixを計算する
*/
static Matrix Vector2mat(const Vector3 vec);
/**@brief
* 外積を計算するためのMatrixを計算する
*/
static Matrix Inv( const Matrix& Mat );
/**@brief
* Creates an identity [n,n] Matrix
* @param Rows Number of Rowns and Columns
* @return Identity Matrix of dimensions [Rows,Rows]
*/
static Matrix Eye( int Rows );
/**@brief
* Returns the dot Product of any two same leght vectors.
* In this case a vector is defined as a [1,n] or [n,1] Matrix.
* Very Flexible Function.
* @param leftM First Vector
* @param rightM Second Vector
* @return Dot Product or Scalar Product.
*/
static float dot( const Matrix& leftM, const Matrix& rightM );
/**@brief Calculates the determinant of a Matrix.
* @param Mat matrix to calculate.
* @return the determinant.
*/
static float det( const Matrix& Mat );
/**@brief Calculates Kronecker product of two Matrix.
* Kronecker product is an operation on two matrices of arbitrary
* size resulting in a block matrix. If A is an m × n matrix
* and B is a p × q matrix, then the Kronecker product A ⊗ B is
* the pm × qn block matrix:
* - -
* | a_11 B ... a_1n B |
* A ⊗ B = | ... ... ... |
* | a_m1 B ... a_mn B |
* - -
* @param Mat_A Matrix m × n
* @param Mat_B Matrix p × q
* @return Kron Matrix pm × qn.
*/
static Matrix kron(const Matrix& Mat_A, const Matrix& Mat_B);
//==== For Kinematics ====//
/**@brief
* Calculates the Rotation Matrix Transform along 'x' axis in radians.
* @param radians rotation angle.
* @return Rotation Matrix[4,4] along 'x' axis.
*/
static Matrix RotX( float radians );
/**@brief
* Calculates the Rotation Matrix Transform along 'y' axis in radians.
* @param radians rotation angle.
* @return Rotation Matrix[4,4] along 'y' axis.
*/
static Matrix RotY( float radians );
/**@brief
* Calculates the Rotation Matrix Transform along 'z' axis in radians.
* @param radians rotation angle.
* @return Rotation Matrix[4,4] along 'z' axis.
*/
static Matrix RotZ( float radians );
/**@brief
* Calculates the Translation Matrix to coordenates (x' y' z').
* @param x axis translation
* @param y axis translation
* @param z axis translation
* @return Translation Matrix[4,4] x'y'z'.
*/
static Matrix Transl( float x, float y, float z );
private:
/**@brief
* Calculates the Determinant of a 3x3 Matrix
* @param Mat Already made sure is a 3 by 3
* @return Float, determinant.
*/
float Det3x3( const Matrix& Mat );
};
#endif /* MATRIXMATH_H */