fsdfds
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
Matrix4 Class Reference
Class definition for a simple matrix, that is optimised for nx4 or 4xn matrices. More...
#include <Matrix4.h>
Public Member Functions | |
Matrix4 (int rows, int cols) | |
Constructor. | |
Matrix4 (const Matrix4 &matrix) | |
Constructor. | |
int | width () |
Determines the number of columns in this matrix. | |
int | height () |
Determines the number of rows in this matrix. | |
float | get (int row, int col) |
Reads the matrix element at the given position. | |
void | set (int row, int col, float v) |
Writes the matrix element at the given position. | |
Matrix4 | transpose () |
Transposes this matrix. | |
Matrix4 | multiply (Matrix4 &matrix, bool transpose=false) |
Multiplies this matrix with the given matrix (if possible). | |
Matrix4 | multiplyT (Matrix4 &matrix) |
Multiplies the transpose of this matrix with the given matrix (if possible). | |
Matrix4 | invert () |
Performs an optimised inversion of a 4x4 matrix. | |
~Matrix4 () | |
Destructor. |
Detailed Description
Class definition for a simple matrix, that is optimised for nx4 or 4xn matrices.
This class is heavily optimised for these commonly used matrices as used in 3D geometry. Whilst this class does support basic operations on matrices of any dimension, it is not intended as a general purpose matrix class as inversion operations are only provided for 4x4 matrices. For programmers needing more flexible Matrix support, the Matrix and MatrixMath classes from Ernsesto Palacios provide a good basis:
https://developer.mbed.org/cookbook/MatrixClass https://developer.mbed.org/users/Yo_Robot/code/MatrixMath/
Definition at line 43 of file Matrix4.h.
Constructor & Destructor Documentation
Matrix4 | ( | int | rows, |
int | cols | ||
) |
Constructor.
Class definition for a simple matrix, optimised for n x 4 or 4 x n matrices.
Create a matrix of the given size.
- Parameters:
-
rows the number of rows in the matrix to be created. cols the number of columns in the matrix to be created.
Matrix4(10, 4); // Creates a Matrix with 10 rows and 4 columns.
This class is heavily optimised for these commonly used matrices as used in 3D geometry, and is not intended as a general purpose matrix class. For programmers needing more flexible Matrix support, the mbed Matrix and MatrixMath classes from Ernsesto Palacios provide a good basis:
https://developer.mbed.org/cookbook/MatrixClass https://developer.mbed.org/users/Yo_Robot/code/MatrixMath/ Constructor. Create a matrix of the given size.
- Parameters:
-
rows the number of rows in the matrix to be created. cols the number of columns in the matrix to be created.
Matrix4(10, 4); // Creates a Matrix with 10 rows and 4 columns.
Definition at line 53 of file Matrix4.cpp.
Constructor.
Create a matrix that is an identical copy of the given matrix.
- Parameters:
-
matrix The matrix to copy.
Matrix newMatrix(matrix); .
Definition at line 76 of file Matrix4.cpp.
~Matrix4 | ( | ) |
Destructor.
Frees any memory consumed by this Matrix4 instance.
Definition at line 278 of file Matrix4.cpp.
Member Function Documentation
float get | ( | int | row, |
int | col | ||
) |
Reads the matrix element at the given position.
- Parameters:
-
row The row of the element to read. col The column of the element to read.
- Returns:
- The value of the matrix element at the given position. 0 is returned if the given index is out of range.
float v = matrix.get(1,2);
Definition at line 137 of file Matrix4.cpp.
int height | ( | ) |
Determines the number of rows in this matrix.
- Returns:
- The number of rows in the matrix.
int r = matrix.height();
Definition at line 119 of file Matrix4.cpp.
Matrix4 invert | ( | ) |
Performs an optimised inversion of a 4x4 matrix.
Only 4x4 matrices are supported by this operation.
- Returns:
- the resultant matrix. An empty matrix is returned if the operation canot be completed.
Matrix result = matrixA.invert();
Definition at line 235 of file Matrix4.cpp.
Multiplies this matrix with the given matrix (if possible).
- Parameters:
-
matrix the matrix to multiply this matrix's values against. transpose Transpose the matrices before multiplication. Defaults to false.
- Returns:
- the resultant matrix. An empty matrix is returned if the operation canot be completed.
Matrix result = matrixA.multiply(matrixB);
Definition at line 199 of file Matrix4.cpp.
Multiplies the transpose of this matrix with the given matrix (if possible).
- Parameters:
-
matrix the matrix to multiply this matrix's values against.
- Returns:
- the resultant matrix. An empty matrix is returned if the operation canot be completed.
Matrix result = matrixA.multiplyT(matrixB);
- Returns:
- the resultant matrix. An empty matrix is returned if the operation canot be completed.
Matrix result = matrixA.multiplyT(matrixB);
void set | ( | int | row, |
int | col, | ||
float | v | ||
) |
Writes the matrix element at the given position.
- Parameters:
-
row The row of the element to write. col The column of the element to write. v The new value of the element.
matrix.set(1,2,42.0);
Definition at line 158 of file Matrix4.cpp.
Matrix4 transpose | ( | ) |
Transposes this matrix.
- Returns:
- the resultant matrix.
matrix.transpose();
Definition at line 175 of file Matrix4.cpp.
int width | ( | ) |
Determines the number of columns in this matrix.
- Returns:
- The number of columns in the matrix.
int c = matrix.width();
Definition at line 105 of file Matrix4.cpp.
Generated on Wed Jul 13 2022 00:58:03 by 1.7.2