# Float3x4

A 3x4 matrix of floating-point values having 3 rows and 4 columns.

A `Float3x4` can represent any affine transformation in 3D space including rotations, scales, shears and translations.

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

In general, a `Float3x4` acts like a `Float4x4` with [0 0 0 1] as the implicit fourth row. The main difference between `Float3x4` and `Float4x4` is that `Float3x4` can't represent a perspective projection matrix.

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

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

## Constructors

` Float3x4::Float3x4()` [code]

Constructs an uninitialized `Float3x4`.

` Float3x4::Float3x4(const Float3& col0, const Float3& col1, const Float3& col2, const Float3& col3)` [code]

Constructs a 3x4 matrix from the given column vectors.

``````Float3x3 m = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}};
``````
`explicit Float3x4::Float3x4(const Float3x3& m3x3, const Float3& pos = {0, 0, 0})` [code]

Constructs a 3x4 matrix from a 3x3 matrix and optional fourth column vector. When the resulting 3x4 matrix transforms a `Float3`, it's equivalent to a transformation by `m3x3` followed by a translation by `pos`.

``````Float4x4 m = {Float3x3::identity(), {5, 0, 0}};
``````

## Conversion Functions

`const Float3x3& Float3x4::asFloat3x3() const` [code]

Returns a const reference to the first three columns as `Float3x3` using type punning. This should only be used as a temporary expression.

`Float4x4 Float3x4::toFloat4x4() const` [code]

Returns a 4x4 matrix by adding [0 0 0 1] as the fourth row.

## Element Access

`Float3& Float3x4::operator[](ureg i)` [code]
`const Float3& Float3x4::operator[](ureg i) const` [code]

Accesses the column vector at the specified index. In general, `m[3]` can be thought of as the translation component.

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

## Comparison Functions

`bool operator==(const Float3x4& a, const Float3x4& b)` [code]
`bool operator!=(const Float3x4& a, const Float3x4& 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 Float3x4 Float3x4::identity()` [code]

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

`static Float3x4 Float3x4::makeScale(const Float3& arg)` [code]

Returns a scale matrix.

`static Float3x4 Float3x4::makeRotation(const Float3& unitAxis, float radians)` [code]

Returns a matrix that performs a counter-clockwise rotation around the specified axis following the right-hand rule. `unitAxis` must have have unit length and the angle is specified in radians.

`static Float3x4 Float3x4::makeTranslation(const Float3& pos)` [code]

Returns a translation matrix.

`static Float3x4 Float3x4::fromQuaternion(const Quaternion& q, const Float3& pos = {0, 0, 0})` [code]

Returns a matrix that performs the same rotation as `q`. If `pos` is specified, it's used as the fourth column, so that the resulting matrix performs the same rotation as `q` followed by a translation by `pos`.

`static Float3x4 Float3x4::fromQuatPos(const QuatPos& qp)` [code]

Returns a matrix that performs the same transformation as `qp`.

## Matrix Operations

`Float3x4 Float3x4::invertedOrtho() const` [code]

A fast method to compute the inverse of a 3x4 matrix whose first three columns are orthogonal. In other words, the input matrix must only consist of a rotation, translation and/or reflection; no scale or shear is allowed.

`Float3 operator*(const Float3x4& m, const Float3& v)` [code]

Transform the vector `v` by the 3x4 matrix `m`. `v` is interpreted as a column vector with an implicit fourth component equal to 1 and premultiplied by `m`. This transformation is equivalent to transforming `v` by the first three columns of `m`, then translating the result by the fourth column, as in `m.asFloat3x3() * v + m[3]`.

If you don't want the implicit fourth component equal to 1, so that no translation is performed, use `m.asFloat3x3() * v` instead.

`Float4 operator*(const Float3x4& m, const Float4& v)` [code]

Interpret `m` as a 4x4 matrix with [0 0 0 1] as the fourth row and use it to transform the vector `v`.

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

Matrix multiplication. All matrices are interpreted as 4x4 matrices with [0 0 0 1] as the implicit fourth row.