Math module

Matrix2

structSource

A 2x2 matrix, row-major: _11, _12, _21, _22, also v[row] as Vector2 rows, coef[row][col] and floats[4]. Matrix2 * Vector2 multiplies by a column vector, and Matrix2 * Matrix2 is the matrix product (a * b applies b first).

ExampleOpen in playground ↗
m := Matrix2.{ 0, -1, 1, 0 }; // quarter turn counter-clockwise
assert(m * xy(1, 0) == xy(0, 1));
assert(m * m == Matrix2.{ -1, 0, 0, -1 });

Fields

_11: float
_12: float
_21: float
_22: float
v: [2] Vector2
coef: [2][2] float
floats: [4] float

See also