From 50b5e6445e78113afb40493d58f018c045e9c18e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 8 Oct 2023 14:52:06 +0100 Subject: [PATCH] a/math: Organize base and api file [NFC] --- src/xrt/auxiliary/math/m_api.h | 28 ++++++++++++++++--------- src/xrt/auxiliary/math/m_base.cpp | 34 +++++++++++++++++++------------ 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/src/xrt/auxiliary/math/m_api.h b/src/xrt/auxiliary/math/m_api.h index 2386f5b1e..1f7e55b53 100644 --- a/src/xrt/auxiliary/math/m_api.h +++ b/src/xrt/auxiliary/math/m_api.h @@ -154,15 +154,6 @@ math_vec3_scalar_mul(float scalar, struct xrt_vec3 *inAndOut); void math_vec3_cross(const struct xrt_vec3 *l, const struct xrt_vec3 *r, struct xrt_vec3 *result); -/*! - * Cross product of a vector. - * - * @relates xrt_vec3 - * @ingroup aux_math - */ -void -math_vec3_f64_cross(const struct xrt_vec3_f64 *l, const struct xrt_vec3_f64 *r, struct xrt_vec3_f64 *result); - /*! * Get translation vector from isometry matrix (col-major). * @@ -181,15 +172,32 @@ math_vec3_translation_from_isometry(const struct xrt_matrix_4x4 *isometry, struc void math_vec3_normalize(struct xrt_vec3 *in); + +/* + * + * 64 bit vector functions. + * + */ + +/*! + * Cross product of a vec3_f64. + * + * @relates xrt_vec3_f64 + * @ingroup aux_math + */ +void +math_vec3_f64_cross(const struct xrt_vec3_f64 *l, const struct xrt_vec3_f64 *r, struct xrt_vec3_f64 *result); + /*! * Normalize a vec3_f64 in place. * - * @relates xrt_vec3 + * @relates xrt_vec3_f64 * @ingroup aux_math */ void math_vec3_f64_normalize(struct xrt_vec3_f64 *in); + /* * * Quat functions. diff --git a/src/xrt/auxiliary/math/m_base.cpp b/src/xrt/auxiliary/math/m_base.cpp index 9095eb64d..6ad7a0256 100644 --- a/src/xrt/auxiliary/math/m_base.cpp +++ b/src/xrt/auxiliary/math/m_base.cpp @@ -172,12 +172,33 @@ math_vec3_normalize(struct xrt_vec3 *in) map_vec3(*in) = map_vec3(*in).normalized(); } +extern "C" void +math_vec3_translation_from_isometry(const struct xrt_matrix_4x4 *transform, struct xrt_vec3 *result) +{ + Eigen::Isometry3f isometry{map_matrix_4x4(*transform)}; + map_vec3(*result) = isometry.translation(); +} + + +/* + * + * Exported 64 bit vector functions. + * + */ + +extern "C" void +math_vec3_f64_cross(const struct xrt_vec3_f64 *l, const struct xrt_vec3_f64 *r, struct xrt_vec3_f64 *result) +{ + map_vec3_f64(*result) = map_vec3_f64(*l).cross(map_vec3_f64(*r)); +} + extern "C" void math_vec3_f64_normalize(struct xrt_vec3_f64 *in) { map_vec3_f64(*in) = map_vec3_f64(*in).normalized(); } + /* * * Exported quaternion functions. @@ -789,19 +810,6 @@ m_mat4_f64_multiply(const struct xrt_matrix_4x4_f64 *left, map_matrix_4x4_f64(*result) = l * r; } -extern "C" void -math_vec3_f64_cross(const struct xrt_vec3_f64 *l, const struct xrt_vec3_f64 *r, struct xrt_vec3_f64 *result) -{ - map_vec3_f64(*result) = map_vec3_f64(*l).cross(map_vec3_f64(*r)); -} - -extern "C" void -math_vec3_translation_from_isometry(const struct xrt_matrix_4x4 *transform, struct xrt_vec3 *result) -{ - Eigen::Isometry3f isometry{map_matrix_4x4(*transform)}; - map_vec3(*result) = isometry.translation(); -} - extern "C" void m_mat4_f64_orientation(const struct xrt_quat *quat, struct xrt_matrix_4x4_f64 *result) {