From 896ba0a0f908adb62609ed53dbf10792687eac88 Mon Sep 17 00:00:00 2001 From: Maxim Kasyanenko Date: Mon, 8 Nov 2021 17:52:31 -0800 Subject: [PATCH] Add dynamic/struct versions of routines --- include/cglm/call/vec2.h | 12 ++++++++++ include/cglm/struct/vec2-ext.h | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/include/cglm/call/vec2.h b/include/cglm/call/vec2.h index d4d3396..6e8101e 100644 --- a/include/cglm/call/vec2.h +++ b/include/cglm/call/vec2.h @@ -149,6 +149,18 @@ CGLM_EXPORT void glmc_vec2_lerp(vec2 from, vec2 to, float t, vec2 dest); +CGLM_EXPORT +void +glmc_vec2_complex_mul(vec2 a, vec2 b, vec2 dest); + +CGLM_EXPORT +void +glmc_vec2_complex_div(vec2 a, vec2 b, vec2 dest); + +CGLM_EXPORT +void +glmc_vec2_complex_conjugate(vec2 a, vec2 dest); + #ifdef __cplusplus } #endif diff --git a/include/cglm/struct/vec2-ext.h b/include/cglm/struct/vec2-ext.h index d77debe..5d6682d 100644 --- a/include/cglm/struct/vec2-ext.h +++ b/include/cglm/struct/vec2-ext.h @@ -195,4 +195,45 @@ glms_vec2_sqrt(vec2s v) { return r; } +/*! + * @brief treat vectors as complex numbers and multiply them as such. + * + * @param[in] a left number + * @param[in] b right number + * @param[out] dest destination number + */ +CGLM_INLINE +vec2s +glms_vec2_complex_mul(vec2s a, vec2s b, vec2s dest) { + glm_vec2_complex_mul(a.raw, b.raw, dest.raw); + return dest; +} + +/*! + * @brief treat vectors as complex numbers and divide them as such. + * + * @param[in] a left number (numerator) + * @param[in] b right number (denominator) + * @param[out] dest destination number + */ +CGLM_INLINE +vec2s +glms_vec2_complex_div(vec2s a, vec2s b, vec2s dest) { + glm_vec2_complex_div(a.raw, b.raw, dest.raw); + return dest; +} + +/*! + * @brief treat the vector as a complex number and conjugate it as such. + * + * @param[in] a the number + * @param[out] dest destination number + */ +CGLM_INLINE +vec2s +glms_vec2_complex_conjugate(vec2s a, vec2s dest) { + glm_vec2_complex_conjugate(a.raw, dest.raw); + return dest; +} + #endif /* cglms_vec2s_ext_h */