Skip to content

rtm/matrix4x4f.h

#include "rtm/matrix4x4f.h"

matrix_get_coord_forward

constexpr vector4f matrix_get_coord_forward(matrix4x4f input)

Returns the axis pointing in the forward direction of the default coordinate system (Z+).

matrix_get_coord_up

constexpr vector4f matrix_get_coord_up(matrix4x4f input)

Returns the axis pointing in the up direction of the default coordinate system (Y+).

matrix_get_coord_cross

constexpr vector4f matrix_get_coord_cross(matrix4x4f input)

Returns the axis pointing in the cross direction of the default coordinate system (X+).

matrix_get_coord_position

constexpr vector4f matrix_get_coord_position(matrix4x4f input)

Returns the axis holding the position of the default coordinate system (W+).

matrix_get_axis

constexpr vector4f matrix_get_axis(matrix4x4f input, axis4 axis)

Returns the desired 4x4 matrix axis.

matrix_set_axis

matrix4x4f matrix_set_axis(matrix4x4f input, vector4f axis_value, axis4 axis)

Returns a new 4x4 matrix where the specified axis has been replaced on the input matrix.

matrix_get_component

float matrix_get_component(matrix4x4f input, axis4 axis, component4 component)

Returns the desired 4x4 matrix component from the specified axis.

matrix_get_component_as_scalar

scalarf matrix_get_component_as_scalar(matrix4x4f input, axis4 axis, component4 component)

Returns the desired 4x4 matrix component from the specified axis.

matrix_set_component

matrix4x4f matrix_set_component(matrix4x4f input, float component_value, axis4 axis, component4 component)

Returns a new 4x4 matrix where the specified axis/component has been replaced on the input matrix.

matrix_mul

matrix4x4f matrix_mul(matrix4x4f lhs, matrix4x4f rhs)

Multiplies two 4x4 matrices. Multiplication order is as follow: local_to_world = matrix_mul(local_to_object, object_to_world)

matrix_mul_vector

vector4f matrix_mul_vector(vector4f vec4, matrix4x4f mtx)

Multiplies a 4x4 matrix and a 4D vector. Multiplication order is as follow: world_position = matrix_mul(local_position, local_to_world)

matrix_transpose

matrix4x4f matrix_transpose(matrix4x4f input)

Transposes a 4x4 matrix.

matrix_inverse

matrix4x4f matrix_inverse(matrix4x4f input)

Inverses a 4x4 matrix. If the input matrix is not invertible, the result is undefined. For a safe alternative, supply a fallback value and a threshold.

matrix4x4f matrix_inverse(matrix4x4f input, matrix4x4f fallback, float threshold=1.0E-8F)

Inverses a 4x4 matrix. If the input matrix has a determinant whose absolute value is below the supplied threshold, the fall back value is returned instead.

matrix_determinant

scalarf matrix_determinant(matrix4x4f input)

Returns the determinant of the input 4x4 matrix.

matrix_minor

scalarf matrix_minor(matrix4x4f input, axis4 row, axis4 column)

Returns the minor of the input 4x4 matrix. See: https://en.wikipedia.org/wiki/Minor_(linear_algebra) The minor is the determinant of the sub-matrix input when the specified row and column are removed.

matrix_cofactor

matrix4x4f matrix_cofactor(matrix4x4f input)

Returns the cofactor matrix of the input 4x4 matrix. See: https://en.wikipedia.org/wiki/Minor_(linear_algebra)#Cofactor_expansion_of_the_determinant

matrix_adjugate

matrix4x4f matrix_adjugate(matrix4x4f input)

Returns the adjugate of the input matrix. See: https://en.wikipedia.org/wiki/Adjugate_matrix

matrix_cast

template<typename matrix_type>
matrix4x4f matrix_cast(const matrix_type& input)

Casts a matrix from one variant to another. Note: When casting a smaller matrix into a larger one, new elements are undefined.

The return value also converts to matrix3x3f, matrix3x3d, matrix3x4f, matrix3x4d and matrix4x4d.

matrix_set

matrix4x4f matrix_set(vector4f x_axis, vector4f y_axis, vector4f z_axis, vector4f w_axis)

Sets all 4 axes and creates a matrix.

The return value also converts to matrix3x4d, matrix3x4f and matrix4x4d.

matrix_identity

matrix4x4f matrix_identity()

Returns the identity matrix.

The return value also converts to matrix3x3d, matrix3x3f, matrix3x4d, matrix3x4f and matrix4x4d.