Hi All!

I’m developing Pool game and I’ve encountered following problem. Maybe it’s rather math problem but I’ve searched many websites and posts, and I can’t get it to work.

My game has a physics engine that calculates ball’s movement. It produce an array , which stores ball’s position and angle in continuous periods of time. This fields are calculated using ball’s velocity, angular velocity and different motions equations.

So, in a time period of t, I have x,y,phi_x,phi_y,phi_z. Coordinates x,y,z are connected with table coordinate system and are unchanged during the ball’s movement.

I draw my ball in a position of x,y simply moving camera with

gl.glTranslated(GUIBalls[0].x_position,GUIBalls[0].y_position,0.0);

That’s OK. But then I have to rotate the ball. I used that formula:

gl.glRotated(GUIBalls[0].fi_x, 1.0f, 0.0f, 0.0f);

gl.glRotated(GUIBalls[0].fi_y, 0.0f, 1.0f, 0.0f);

gl.glRotated(GUIBalls[0].fi_z, 0.0f, 0.0f, 1.0f);

But of course It’s not working properly.

So the problem is, I calculate ball’s angle change in a period of time, using angular velocities in cordinates x,y,z.

And I do not know how to rotate it using glRotate.

I know that rotation is not commutative, which means rotating 90 degrees on x and then 90degrees on y is not the same as doing it in a different order.

How I can find a fixed axis and angle when I have three angles connected with coordinates x,y,z.

Thank you for your help!