# Float2x2

A 2x2 matrix of floating-point values.

A `Float2x2` can represent any linear transformation on the 2D plane without a translation component, such as rotation, scale or shear.

The matrix is stored in column-major order. In other words, it's an array of two `Float2` column vectors.

`#include <ply-math/Matrix.h>`

Also included from `<ply-math/Base.h>`.

## Constructors

` Float2x2::Float2x2()` [code]

Constructs an uninitialized `Float2x2`.

` Float2x2::Float2x2(const Float2& col0, const Float2& col1)` [code]

Constructs a 2x2 matrix from the given column vectors.

``````Float2x2 m = {{1, 0}, {0, 1}};
``````

## Element Access

`Float2& Float2x2::operator[](ureg i)` [code]
`const Float2& Float2x2::operator[](ureg i) const` [code]

Accesses the column vector at the specified index.

``````Float2x2 m = {{1, 0}, {0, 1}};
m[0].x = -1;
StdOut::text() << m[1];  // "{0, 1}"
``````

## Comparison Functions

`bool operator==(const Float2x2& a, const Float2x2& b)` [code]
`bool operator!=(const Float2x2& a, const Float2x2& b)` [code]

Returns `true` if the matrices are equal (or not equal) using floating-point comparison. In particular, a component with a value of `0.f` is equal to a component with a value of `-0.f`.

## Creation Functions

`static Float2x2 Float2x2::identity()` [code]

Returns the identity matrix `{{1, 0}, {0, 1}}`.

`static Float2x2 Float2x2::makeScale(const Float2& scale)` [code]

Returns a scale matrix.

`static Float2x2 Float2x2::makeRotation(float radians)` [code]

Returns a counter-clockwise rotation matrix. The angle is specified in radians.

`static Float2x2 Float2x2::fromComplex(const Float2& c)` [code]

Returns a rotation and scale matrix whose first column is given by `c`. Transforming a vector by this matrix is equivalent to premultiplying by the vector by `c` on the complex plane.

``````Float2x2::fromComplex({1, 0})  // returns the identity matrix
``````

## Matrix Operations

`Float2x2 Float2x2::transposed() const` [code]

Returns the transpose of the 2x2 matrix. If the matrix is orthogonal (in other words, it consists only of a rotation and/or reflection), this function also returns the inverse matrix.

`Float2 operator*(const Float2x2& m, const Float2& v)` [code]

Transform a vector using a matrix. `v` is treated as a column vector and premultiplied by the matrix `m`.

`Float2x2 operator*(const Float2x2& a, const Float2x2& b)` [code]

Matrix multiplication.