mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 04:36:07 +00:00
a/math: Add math_matrix_4x4_transform_vec3
This commit is contained in:
parent
06ee685e9a
commit
3c9ef82060
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue