aux/math: Implement math_matrix_4x4_inverse_view_projection.

This commit is contained in:
Lubosz Sarnecki 2020-09-08 19:41:24 +02:00 committed by Jakob Bornecrantz
parent 74f7d03830
commit 7035490ed7
2 changed files with 24 additions and 0 deletions

View file

@ -346,6 +346,18 @@ math_matrix_4x4_model(const struct xrt_pose *pose,
const struct xrt_vec3 *size,
struct xrt_matrix_4x4 *result);
/*!
* Compute inverse view projection matrix,
* using only the starting 3x3 block of the view.
*
* @relates xrt_matrix_4x4
* @ingroup aux_math
*/
void
math_matrix_4x4_inverse_view_projection(const struct xrt_matrix_4x4 *view,
const struct xrt_matrix_4x4 *projection,
struct xrt_matrix_4x4 *result);
/*
*
* Pose functions.

View file

@ -350,6 +350,18 @@ math_matrix_4x4_model(const struct xrt_pose *pose,
map_matrix_4x4(*result) = transformation.matrix();
}
void
math_matrix_4x4_inverse_view_projection(const struct xrt_matrix_4x4 *view,
const struct xrt_matrix_4x4 *projection,
struct xrt_matrix_4x4 *result)
{
Eigen::Matrix4f v = copy(view);
Eigen::Matrix4f v3 = Eigen::Matrix4f::Identity();
v3.block<3, 3>(0, 0) = v.block<3, 3>(0, 0);
Eigen::Matrix4f vp = copy(projection) * v3;
map_matrix_4x4(*result) = vp.inverse();
}
/*
*
* Exported pose functions.