mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-29 18:08:29 +00:00
a/math: Add math_quat_to_euler_angles
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2312>
This commit is contained in:
parent
7150279e2b
commit
71b5d37e7e
|
@ -222,6 +222,14 @@ math_quat_from_angle_vector(float angle_rads, const struct xrt_vec3 *vector, str
|
|||
void
|
||||
math_quat_from_euler_angles(const struct xrt_vec3 *angles, struct xrt_quat *result);
|
||||
|
||||
/*!
|
||||
* Create a rotation from a quaternion to euler angles
|
||||
* @relates xrt_quat
|
||||
* @ingroup aux_math
|
||||
*/
|
||||
void
|
||||
math_quat_to_euler_angles(const struct xrt_quat *quat, struct xrt_vec3 *euler_angles);
|
||||
|
||||
/*!
|
||||
* Create a rotation from a 3x3 rotation (row major) matrix.
|
||||
*
|
||||
|
|
|
@ -222,6 +222,17 @@ math_quat_from_euler_angles(const struct xrt_vec3 *angles, struct xrt_quat *resu
|
|||
Eigen::AngleAxisf(angles->x, Eigen::Vector3f::UnitX());
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
math_quat_to_euler_angles(const struct xrt_quat *quat, struct xrt_vec3 *euler_angles)
|
||||
{
|
||||
Eigen::Quaternionf eigen_quat(quat->w, quat->x, quat->y, quat->z);
|
||||
Eigen::Vector3f eigen_euler = eigen_quat.toRotationMatrix().eulerAngles(2, 1, 0);
|
||||
|
||||
euler_angles->x = eigen_euler.x();
|
||||
euler_angles->y = eigen_euler.y();
|
||||
euler_angles->z = eigen_euler.z();
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
math_quat_from_matrix_3x3(const struct xrt_matrix_3x3 *mat, struct xrt_quat *result)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue