Skip to content

rtm/matrix3x3d.h

#include "rtm/matrix3x3d.h"

matrix_get_coord_forward

constexpr vector4d matrix_get_coord_forward(matrix3x3d input)

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

matrix_get_coord_up

constexpr vector4d matrix_get_coord_up(matrix3x3d input)

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

matrix_get_coord_cross

constexpr vector4d matrix_get_coord_cross(matrix3x3d input)

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

matrix_get_axis

constexpr vector4d matrix_get_axis(matrix3x3d input, axis3 axis)

Returns the desired 3x3 matrix axis.

matrix_set_axis

matrix3x3d matrix_set_axis(matrix3x3d input, vector4d axis_value, axis3 axis)

Returns a new 3x3 matrix where the specified axis has been replaced on the input matrix.

matrix_get_component

double matrix_get_component(matrix3x3d input, axis3 axis, component3 component)

Returns the desired 3x3 matrix component from the specified axis.

matrix_get_component_as_scalar

scalard matrix_get_component_as_scalar(matrix3x3d input, axis3 axis, component3 component)

Returns the desired 3x3 matrix component from the specified axis.

matrix_set_component

matrix3x3d matrix_set_component(matrix3x3d input, double component_value, axis3 axis, component3 component)

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

quat_from_matrix

quatd quat_from_matrix(matrix3x3d input)

Converts a 3x3 matrix into a rotation quaternion.

matrix_mul

matrix3x3d matrix_mul(matrix3x3d lhs, matrix3x3d rhs)

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

matrix_mul_vector3

vector4d matrix_mul_vector3(vector4d vec3, matrix3x3d_argn mtx)

Multiplies a 3x3 matrix and a 3D vector. Multiplication order is as follow: world_position = matrix_mul(local_vector, local_to_world) Note: The proper way to transform a normal by a matrix with non-uniform scale is to multiply the normal with the cofactor matrix. See: https://github.com/graphitemaster/normals_revisited

matrix_transpose

matrix3x3d matrix_transpose(matrix3x3d input)

Transposes a 3x3 matrix.

matrix_inverse

matrix3x3d matrix_inverse(matrix3x3d input)

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

matrix3x3d matrix_inverse(matrix3x3d input, matrix3x3d fallback, double threshold=1.0E-8)

Inverses a 3x3 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

scalard matrix_determinant(matrix3x3d input)

Returns the determinant of the input 3x3 matrix.

matrix_minor

scalard matrix_minor(matrix3x3d input, axis3 row, axis3 column)

Returns the minor of the input 3x3 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

matrix3x3d matrix_cofactor(matrix3x3d input)

Returns the cofactor matrix of the input 3x3 matrix. See: https://en.wikipedia.org/wiki/Minor_(linear_algebra)#Cofactor_expansion_of_the_determinant Note: The proper way to transform a normal by a matrix with non-uniform scale is to multiply the normal with the cofactor matrix. See: https://github.com/graphitemaster/normals_revisited

matrix_adjugate

matrix3x3d matrix_adjugate(matrix3x3d input)

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

matrix_remove_scale

matrix3x3d matrix_remove_scale(matrix3x3d input)

Removes the 3D scale from a 3x3 matrix. Note that if the scaling is 0.0 for a particular axis, the original rotation axis cannot be recovered trivially and no attempt is done to do so. In theory, we could use the other axes to try and recover it.

matrix_from_quat

matrix3x3d matrix_from_quat(quatd quat)

Converts a rotation quaternion into a 3x3 or 3x4 affine matrix.

The return value also converts to matrix3x4d.

matrix_from_rotation

matrix3x3d matrix_from_rotation(quatd quat)

Converts a rotation quaternion into a 3x3 or 3x4 affine matrix.

The return value also converts to matrix3x4d.

matrix_from_scale

matrix3x3d matrix_from_scale(vector4d scale)

Converts a 3D scale vector into a 3x3 or 3x4 affine matrix.

The return value also converts to matrix3x4d.

matrix_cast

template<typename matrix_type>
matrix3x3d 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, matrix3x4f, matrix3x4d, matrix4x4f and matrix4x4d.

matrix_set

constexpr matrix3x3d matrix_set(vector4d x_axis, vector4d y_axis, vector4d z_axis)

Sets all 3 axes and creates a matrix.

matrix_identity

matrix3x3d matrix_identity()

Returns the identity matrix.

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