mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-28 17:38:27 +00:00
aux/math: Implement math_matrix_4x4_inverse_view_projection.
This commit is contained in:
parent
74f7d03830
commit
7035490ed7
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue