Float4x4
A 4x4 matrix of floatingpoint values.
A Float4x4
can represent any affine transformation in 3D space including rotations, scales, shears
and translations. Unlike Float3x4
, it can also represent perspective projections.
The matrix is stored in columnmajor order. In other words, it's an array of four Float4
column
vectors.
Header File
#include <plymath/Matrix.h>
Also included from <plymath/Base.h>
.
Constructors

Constructs an uninitialized
Float4x4
. 
Constructs a 4x4 matrix from the given column vectors.
Float4x4 m = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};

Constructs a 4x4 matrix by concatenating a 3x3 matrix with an optional fourth column vector and adding [0 0 0 1] as the fourth row. When the resulting 4x4 matrix transforms a
Float3
, it's equivalent to a transformation bym3x3
followed by a translation bypos
.Float4x4 m = {Float3x3::identity(), {5, 0, 0}};

Returns a 3x3 matrix by truncating the fourth column and fourth row of the 4x4 matrix.

Returns a 3x4 matrix by truncating the fourth row of the 4x4 matrix.

Accesses the column vector at the specified index.
Float4x4 m = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}; m[0].x = 1; StdOut::text() << m[3]; // "{0, 0, 0, 1}"
bool operator==(const Float4x4& a, const Float4x4& b)
[code]bool operator!=(const Float4x4& a, const Float4x4& b)
[code]
Returns
true
if the matrices are equal (or not equal) using floatingpoint comparison. In particular, a component with a value of0.f
is equal to a component with a value of0.f
. 
Returns the identity matrix
{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}
. 
Returns a scale matrix.

Returns a matrix that performs a counterclockwise rotation around the specified axis following the righthand rule.
unitAxis
must have have unit length and the angle is specified in radians. 
Returns a translation matrix.

Returns a matrix that performs the same rotation as
q
. Ifpos
is specified, it's used as the fourth column, so that the resulting matrix performs the same rotation asq
followed by a translation bypos
. 
Returns a matrix that performs the same transformation as
qp
. 
Returns a perspective projection matrix that maps a 3D frustum to OpenGL clip space in homogeneous coordinates. OpenGL clip space goes from 1 at the near plane to +1 at the far plane, with x and y coordinates in the range [1, 1].
Assuming a righthanded coordinate system, the 3D frustum starts at the origin, faces the z direction, and intersects the z = 1 plane at the rectangle given by
frustum
. Use therectFromFov()
helper function to convert a fieldofview angle and aspect ratio to afrustum
rectangle.Float4x4 p = Float4x4::makeProjection(rectFromFov(Pi / 2, 16.f / 9), 1, 100);
zNear
andzFar
are interpreted as distances from the origin and must be positive values. Since the 3D frustum faces the z direction, the actual near and far clip planes are given by z =zNear
and z =zFar
.Note: This type of projection matrix works, but is considered outdated. More modern projection matrices, such as those using reversed z or having an infinite far plane, typically offer better precision, but those aren't implemented in Plywood yet.

Returns an orthographic projection matrix that maps a 3D box to OpenGL clip space. OpenGL clip space goes from 1 at the near plane to +1 at the far plane, with x and y coordinates in the range [1, 1].
Assuming a righthanded coordinate system, the 3D box being transformed faces the z direction.
zNear
andzFar
are interpreted as distances from the origin, so the actual near and far clip planes are given by z =zNear
and z =zFar
. 
Returns the transpose of the 4x4 matrix.

A fast method to compute the inverse of a 4x4 matrix whose fourth row is [0 0 0 1] and 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.

Transform a vector using a matrix.
v
is treated as a column vector and premultiplied by the matrixm
. Float4x4 operator*(const Float4x4& a, const Float4x4& b)
[code]
Matrix multiplication.
Float3x4
arguments are interpreted as 4x4 matrices with [0 0 0 1] as the implicit fourth row.