From 03d5699f320fad2525bedc009a5c6b7db8104b78 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Mon, 17 Oct 2022 23:57:41 +0300 Subject: [PATCH] new rotation function: spin; rotate around self at any position --- include/cglm/affine.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/cglm/affine.h b/include/cglm/affine.h index d0e5bc9..8785a0a 100644 --- a/include/cglm/affine.h +++ b/include/cglm/affine.h @@ -382,6 +382,21 @@ glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) { glm_translate(m, pivotInv); } +/*! + * @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position) + * + * @param[in, out] m affine transfrom + * @param[in] angle angle (radians) + * @param[in] axis axis + */ +CGLM_INLINE +void +glm_spin(mat4 m, float angle, vec3 axis) { + CGLM_ALIGN_MAT mat4 rot; + glm_rotate_atm(rot, m[3], angle, axis); + glm_mat4_mul(m, rot, m); +} + /*! * @brief decompose scale vector *