new rotation function: spin; rotate around self at any position

This commit is contained in:
Recep Aslantas
2022-10-17 23:57:41 +03:00
parent 199d1fa031
commit 03d5699f32

View File

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