a/math: Add math_matrix_4x4_transform_vec3

This commit is contained in:
Christoph Haag 2022-05-26 02:12:13 +02:00 committed by Jakob Bornecrantz
parent 06ee685e9a
commit 3c9ef82060
2 changed files with 29 additions and 0 deletions

View file

@ -477,6 +477,17 @@ math_matrix_3x3_transform_vec3(const struct xrt_matrix_3x3 *left,
const struct xrt_vec3 *right,
struct xrt_vec3 *result_out);
/*!
* Transform a vec3 by a 4x4 matrix, extending the vector with w = 1.0
*
* @see xrt_matrix_4x4
* @ingroup aux_math
*/
void
math_matrix_4x4_transform_vec3(const struct xrt_matrix_4x4 *left,
const struct xrt_vec3 *right,
struct xrt_vec3 *result_out);
/*!
* Transform a double vec3 by a 3x3 double matrix
*

View file

@ -551,6 +551,24 @@ math_matrix_3x3_transform_vec3(const struct xrt_matrix_3x3 *left,
map_vec3(*result_out) = m * copy(right);
}
extern "C" void
math_matrix_4x4_transform_vec3(const struct xrt_matrix_4x4 *left,
const struct xrt_vec3 *right,
struct xrt_vec3 *result_out)
{
Eigen::Matrix4f m = copy(left);
Eigen::Vector4f v;
v << right->x, right->y, right->z, 1.0;
Eigen::Vector4f res;
res = m * v;
result_out->x = res.x();
result_out->y = res.y();
result_out->z = res.z();
}
extern "C" void
math_matrix_3x3_multiply(const struct xrt_matrix_3x3 *left,
const struct xrt_matrix_3x3 *right,