From bd68c0e5f53af865368460bbf4a12944f6a4d666 Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki Date: Fri, 27 Nov 2020 16:45:51 +0100 Subject: [PATCH] aux/math: Implement math_matrix_2x2_multiply. --- src/xrt/auxiliary/math/m_api.h | 11 +++++++++++ src/xrt/auxiliary/math/m_base.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/xrt/auxiliary/math/m_api.h b/src/xrt/auxiliary/math/m_api.h index 3a0c1a915..475097328 100644 --- a/src/xrt/auxiliary/math/m_api.h +++ b/src/xrt/auxiliary/math/m_api.h @@ -300,6 +300,17 @@ math_quat_rotate_derivative(const struct xrt_quat *rot, * */ +/*! + * Multiply Matrix2x2. + * + * @relates xrt_matrix_2x2 + * @ingroup aux_math + */ +void +math_matrix_2x2_multiply(const struct xrt_matrix_2x2 *left, + const struct xrt_matrix_2x2 *right, + struct xrt_matrix_2x2 *result); + void math_matrix_3x3_transform_vec3(const struct xrt_matrix_3x3 *left, const struct xrt_vec3 *right, diff --git a/src/xrt/auxiliary/math/m_base.cpp b/src/xrt/auxiliary/math/m_base.cpp index 33a4e1162..3975a0d98 100644 --- a/src/xrt/auxiliary/math/m_base.cpp +++ b/src/xrt/auxiliary/math/m_base.cpp @@ -293,6 +293,17 @@ math_quat_rotate_derivative(const struct xrt_quat *quat, * */ +void +math_matrix_2x2_multiply(const struct xrt_matrix_2x2 *left, + const struct xrt_matrix_2x2 *right, + struct xrt_matrix_2x2 *result) +{ + result->v[0] = left->v[0] * right->v[0] + left->v[1] * right->v[2]; + result->v[1] = left->v[0] * right->v[1] + left->v[1] * right->v[3]; + result->v[2] = left->v[2] * right->v[0] + left->v[3] * right->v[2]; + result->v[3] = left->v[2] * right->v[1] + left->v[3] * right->v[3]; +} + extern "C" void math_matrix_3x3_transform_vec3(const struct xrt_matrix_3x3 *left, const struct xrt_vec3 *right,