mirror of
https://github.com/recp/cglm.git
synced 2025-12-25 12:55:04 +00:00
rotate around single axis
This commit is contained in:
@@ -98,4 +98,58 @@ glm_scale1_self(mat4 m, float s) {
|
||||
m[2][2] *= s;
|
||||
}
|
||||
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_rotate_x(mat4 m, float rad, mat4 dest) {
|
||||
float cosVal;
|
||||
float sinVal;
|
||||
mat4 t = GLM_MAT_IDENTITY_4F;
|
||||
|
||||
cosVal = cos(rad);
|
||||
sinVal = sin(rad);
|
||||
|
||||
t[1][1] = cosVal;
|
||||
t[1][2] = sinVal;
|
||||
t[2][1] = -sinVal;
|
||||
t[2][2] = cosVal;
|
||||
|
||||
glm_mat_mul4(t, m, dest);
|
||||
}
|
||||
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_rotate_y(mat4 m, float rad, mat4 dest) {
|
||||
float cosVal;
|
||||
float sinVal;
|
||||
mat4 t = GLM_MAT_IDENTITY_4F;
|
||||
|
||||
cosVal = cos(rad);
|
||||
sinVal = sin(rad);
|
||||
|
||||
t[0][0] = cosVal;
|
||||
t[0][2] = -sinVal;
|
||||
t[2][0] = sinVal;
|
||||
t[2][2] = cosVal;
|
||||
|
||||
glm_mat_mul4(t, m, dest);
|
||||
}
|
||||
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_rotate_z(mat4 m, float rad, mat4 dest) {
|
||||
float cosVal;
|
||||
float sinVal;
|
||||
mat4 t = GLM_MAT_IDENTITY_4F;
|
||||
|
||||
cosVal = cos(rad);
|
||||
sinVal = sin(rad);
|
||||
|
||||
t[0][0] = cosVal;
|
||||
t[0][1] = sinVal;
|
||||
t[1][0] = -sinVal;
|
||||
t[1][1] = cosVal;
|
||||
|
||||
glm_mat_mul4(t, m, dest);
|
||||
}
|
||||
|
||||
#endif /* cglm_affine_h */
|
||||
|
||||
Reference in New Issue
Block a user