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.
Header File
#include <ply-math/Matrix.h>
Also included from <ply-math/Base.h>
.
Constructors
-
Constructs an uninitialized
Float3x4
. -
Constructs a 3x4 matrix from the given column vectors.
Float3x3 m = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}};
-
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 bym3x3
followed by a translation bypos
.Float4x4 m = {Float3x3::identity(), {5, 0, 0}};
-
Returns a const reference to the first three columns as
Float3x3
using type punning. This should only be used as a temporary expression. -
Returns a 4x4 matrix by adding [0 0 0 1] as the fourth row.
-
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}"
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 of0.f
is equal to a component with a value of-0.f
. -
Returns the identity matrix
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {0, 0, 0}}
. -
Returns a scale matrix.
-
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. -
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
. -
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.
-
Transform the vector
v
by the 3x4 matrixm
.v
is interpreted as a column vector with an implicit fourth component equal to 1 and premultiplied bym
. This transformation is equivalent to transformingv
by the first three columns ofm
, then translating the result by the fourth column, as inm.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. -
Interpret
m
as a 4x4 matrix with [0 0 0 1] as the fourth row and use it to transform the vectorv
. 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.