A 2×2 matrix can be constructed as an identity matrix or you can specify the values you'd like entered as floats.
The values of the matrix are stored in such a way that you can access them both by the []
operator, and as member variables.
As an array:
float ImpulsePhysics::Matrix2x2::Determinant() const { return asArray[0] * asArray[3] - asArray[1] * asArray[2]; }
As variables:
float ImpulsePhysics::Matrix2x2::Determinant() const { return _11 * _22 - _12 * _21; }
2×2 matrices offer the following functions within their class:
Transpose
Determinant
Inverse
Adjugate
(aka adjoint)Note that none of these functions will modify the current matrix object, rather they return a new 2×2 matrix with the operation applied.
As part of the ImpulsePhysics::Matrices
namespace, you also get access to these utility functions:
Cut2x2
, which 'cuts' a 2×2 matrix out of a 3x3 matrixMinor
Cofactor