I'm trying to write a little program with a bouncing cube but I can't find the right x, y, z and angle for it. I have these lines:
modelMatrix = glm::mat4(1)
modelMatrix *= Translate(x, y, z)
modelMatrix *= RotateOZ(angle)
RenderMesh(mesh["cube"], shaders["V"], modelMatrix)
I added a picture to make it easier to understand. My cube will start at x0, y0, z0(we can leave the z out of this because for now I want the cube to move only in the OX axis and OY). I added a arrow the cube so I can represent the rotation better. First he will move forward on the OX and OY axis while rotating in the range of [0 - 90] grades when he will hit X1(which is X / 2) and Y1 then he will rotate in the range of [90 - 180] grades while moving forward on the OX and descending on the OY. I hope that made sense.
My problem is that I can't find the right x, y and angle to give to these transformations so I can get the animation that I want. I tried to add to x, y and angle the same value such as 0.1 and the result is close but not perfect. RotateOZ return a mat4:
return glm::mat4(
cos(angle), -sin(angle), 0, 0,
sin(angle), cos(angle), 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
);
Thank you for your time!