1
votes

I'm trying to rotate an object (set of vertices) about the origin in opengl.

The object being a Carriage in a Ferris wheel which must not must stay upright during the rotation. So far all I've got is the following transformation which rotates the carriage but does not stay upright. This uses basic rotation transformation about the origin at a 72 degree angle. The model martix looks something like this:

g_modelMatrix[i] = glm::mat4(1.0f) * glm::rotate(glm::radians(-72.0f), glm::vec3(0.0f, 0.0f, 1.0f)); 

where glm::mat4(1.0f)is an identity matrix

The end result transforms the carriage but does not make it upright. enter image description here What transformation would be appropriate for this kind of problem?

1
Rotate the carriage the opposite way before translating it?user253751
Do you mean rotating anti clockwise (72deg) then translating (x,y) to get it back to the original position, then again rotate clockwise (72deg )?Arpan Kc
Yes, I do mean that.user253751
But how do I figure out x and y , for every transformation?Arpan Kc
If the centre of the wheel is not at the origin, then first translate the wheel to the origin, then rotate, then translate back. This will apply only to the wheel; the rest of objects need a different view-matrix ( another rendering call).Ripi2

1 Answers

1
votes

This is the approach I used to solve the problem.

rotate(i * 72°) * translate(r, 0, 0) * rotate(-i * 72°)