aux/math: Add math_quat_slerp()

This commit is contained in:
Dan Weatherford 2021-06-11 01:20:57 -05:00 committed by Jakob Bornecrantz
parent 4581a7a9a6
commit fabf01ff39
2 changed files with 21 additions and 0 deletions

View file

@ -290,6 +290,15 @@ void
math_quat_rotate_derivative(const struct xrt_quat *rot, const struct xrt_vec3 *deriv, struct xrt_vec3 *result);
/*!
* Slerp (spherical linear interpolation) between two quaternions
*
* @relates xrt_quat
* @ingroup aux_math
*/
void
math_quat_slerp(const struct xrt_quat *left, const struct xrt_quat *right, float t, struct xrt_quat *result);
/*
*
* Matrix functions

View file

@ -299,6 +299,18 @@ math_quat_rotate_derivative(const struct xrt_quat *quat, const struct xrt_vec3 *
*result = ret;
}
extern "C" void
math_quat_slerp(const struct xrt_quat *left, const struct xrt_quat *right, float t, struct xrt_quat *result)
{
assert(left != NULL);
assert(right != NULL);
assert(result != NULL);
auto l = copy(left);
auto r = copy(right);
map_quat(*result) = l.slerp(t, r);
}
/*
*