diff --git a/include/cglm/affine.h b/include/cglm/affine.h index 8785a0a..38f19b3 100644 --- a/include/cglm/affine.h +++ b/include/cglm/affine.h @@ -24,6 +24,7 @@ CGLM_INLINE void glm_rotate(mat4 m, float angle, vec3 axis); CGLM_INLINE void glm_rotate_at(mat4 m, vec3 pivot, float angle, vec3 axis); CGLM_INLINE void glm_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis); + CGLM_INLINE void glm_spin(mat4 m, float angle, vec3 axis); CGLM_INLINE void glm_decompose_scalev(mat4 m, vec3 s); CGLM_INLINE bool glm_uniscaled(mat4 m); CGLM_INLINE void glm_decompose_rs(mat4 m, mat4 r, vec3 s); diff --git a/include/cglm/call/affine.h b/include/cglm/call/affine.h index c11405b..4b5b2bc 100644 --- a/include/cglm/call/affine.h +++ b/include/cglm/call/affine.h @@ -81,6 +81,10 @@ CGLM_EXPORT void glmc_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis); +CGLM_EXPORT +void +glmc_spin(mat4 m, float angle, vec3 axis); + CGLM_EXPORT void glmc_decompose_scalev(mat4 m, vec3 s); diff --git a/include/cglm/struct/affine.h b/include/cglm/struct/affine.h index cd23226..4176200 100644 --- a/include/cglm/struct/affine.h +++ b/include/cglm/struct/affine.h @@ -23,6 +23,7 @@ CGLM_INLINE mat4s glms_rotate(mat4s m, float angle, vec3s axis); CGLM_INLINE mat4s glms_rotate_at(mat4s m, vec3s pivot, float angle, vec3s axis); CGLM_INLINE mat4s glms_rotate_atm(mat4s m, vec3s pivot, float angle, vec3s axis); + CGLM_INLINE mat4s glms_spin(mat4s m, float angle, vec3s axis); CGLM_INLINE vec3s glms_decompose_scalev(mat4s m); CGLM_INLINE bool glms_uniscaled(mat4s m); CGLM_INLINE void glms_decompose_rs(mat4s m, mat4s * r, vec3s * s); @@ -226,7 +227,7 @@ glms_rotate_make(float angle, vec3s axis) { * @param[in] m affine transfrom * @param[in] angle angle (radians) * @param[in] axis axis - * @returns affine transfrom + * @returns affine transfrom */ CGLM_INLINE mat4s @@ -273,6 +274,21 @@ glms_rotate_atm(mat4s m, vec3s pivot, float angle, vec3s axis) { return m; } +/*! + * @brief rotate existing transform matrix around given axis by angle around self (doesn't affected by position) + * + * @param[in] m affine transfrom + * @param[in] angle angle (radians) + * @param[in] axis axis + * @returns affine transfrom + */ +CGLM_INLINE +mat4s +glms_spin(mat4s m, float angle, vec3s axis) { + glm_spin(m.raw, angle, axis.raw); + return m; +} + /*! * @brief decompose scale vector * diff --git a/src/affine.c b/src/affine.c index a818bd1..a905da9 100644 --- a/src/affine.c +++ b/src/affine.c @@ -110,6 +110,12 @@ glmc_rotate_atm(mat4 m, vec3 pivot, float angle, vec3 axis) { glm_rotate_atm(m, pivot, angle, axis); } +CGLM_EXPORT +void +glmc_spin(mat4 m, float angle, vec3 axis) { + glm_spin(m, angle, axis); +} + CGLM_EXPORT void glmc_decompose_scalev(mat4 m, vec3 s) {