Matrix22#

struct Matrix22#

2x2 matrix representation with column-major storage.

This structure represents a 2x2 matrix stored in column-major order. It provides basic matrix operations including arithmetic, element access, and static identity matrix creation.

The matrix is stored as two Vec2 columns, making it suitable for 2D transformations and linear algebra operations.

Public Functions

inline Matrix22()#

Default constructor creating an uninitialized matrix.

inline Matrix22(float a, float b, float c, float d)#

Constructor from individual matrix elements.

Creates a matrix with the specified elements: | a b | | c d |

Parameters:
  • a[in] Element at position (0,0)

  • b[in] Element at position (0,1)

  • c[in] Element at position (1,0)

  • d[in] Element at position (1,1)

inline Matrix22(const Vec2 &c1, const Vec2 &c2)#

Constructor from two column vectors.

Parameters:
  • c1[in] First column vector

  • c2[in] Second column vector

inline float operator()(int i, int j) const#

Const element access operator.

Parameters:
  • i[in] Row index (0 or 1)

  • j[in] Column index (0 or 1)

Returns:

Const reference to the matrix element at (i,j)

inline float &operator()(int i, int j)#

Mutable element access operator.

Parameters:
  • i[in] Row index (0 or 1)

  • j[in] Column index (0 or 1)

Returns:

Mutable reference to the matrix element at (i,j)

Public Members

Vec2 cols[2]#

Column vectors of the matrix.

The matrix is stored as two column vectors in column-major order. cols[0] represents the first column, cols[1] represents the second column.

Public Static Functions

static inline Matrix22 Identity()#

Creates a 2x2 identity matrix.

Returns:

Identity matrix with 1s on the diagonal and 0s elsewhere