a/math: add math_matrix_2x2_transform_vec2

This commit is contained in:
Aidan Thornton 2022-06-10 18:57:47 +01:00 committed by Jakob Bornecrantz
parent 96fb9ce34a
commit 4840def448
2 changed files with 22 additions and 0 deletions

View file

@ -428,6 +428,17 @@ math_matrix_2x2_multiply(const struct xrt_matrix_2x2 *left,
const struct xrt_matrix_2x2 *right,
struct xrt_matrix_2x2 *result_out);
/*!
* Transform a vec2 by a 2x2 matrix
*
* @see xrt_matrix_2x2
* @ingroup aux_math
*/
void
math_matrix_2x2_transform_vec2(const struct xrt_matrix_2x2 *left,
const struct xrt_vec2 *right,
struct xrt_vec2 *result_out);
/*!
* Initialize a 3x3 matrix to the identity matrix
*

View file

@ -456,6 +456,17 @@ math_matrix_2x2_multiply(const struct xrt_matrix_2x2 *left,
*result_out = result;
}
extern "C" void
math_matrix_2x2_transform_vec2(const struct xrt_matrix_2x2 *left,
const struct xrt_vec2 *right,
struct xrt_vec2 *result_out)
{
const struct xrt_matrix_2x2 l = *left;
const struct xrt_vec2 r = *right;
struct xrt_vec2 result = {l.v[0] * r.x + l.v[1] * r.y, l.v[2] * r.x + l.v[3] * r.y};
*result_out = result;
}
extern "C" void
math_matrix_3x3_identity(struct xrt_matrix_3x3 *mat)
{