add missing spin impl

This commit is contained in:
Recep Aslantas
2022-10-18 07:38:06 +03:00
parent 03d5699f32
commit c0bd65027a
4 changed files with 28 additions and 1 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
@@ -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
*

View File

@@ -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) {