I am using glm::rotate
to rotate a transformation matrix for a cube in a scene.
"cube->t = glm::rotate(cube->t, stepTime * 50.f, glm::vec3(0.f, 1.f, 0.f));"
is called once per frame, where cube->t
is the matrix in question.
The strange thing is that over the course of 20 minutes (or two minutes if I rotate by stepTime * 5000.f
instead of stepTime * 50.f
), the cube scales noticeably on the X and Z axes, where the scaling on those two axes is the same at all times (the height of the cube never changes, but the width and depth change by exactly the same amount). In the case of 5000.f
, becoming smaller, and with the normal 50.f
or 100.f
, becoming larger.
I thought this might be a question of rounding error, but other than that I have no idea what could be causing it. Is this rounding error? Can I solve it by normalizing the matrix on a regular basis? Does glm have a function for normalizing matrices, or do I have to write one myself?