Advanced Rotating

The code I am trying to write is simple but complex. I have a beam on a surface on the left and the right side extends out where the top is held by a spring.

I have all the formulas down, there just one problem that i can’t find any other method to do. You need the spring equilibrium and the spring distance from equilibrium. I have the beam rotating on the correct pivot point, but if I just use glRotatef, I don’t know the coordinates when it is rotating, which I need to know where the spring is at on the right side.

I figure theres a way where I can adjust the coordinates of the beam myself without using glRotatef, but I have no idea how.

Any help or suggestions would be greatly appreciated.

I don’t understand the problem space very well…The beam is the rotating object? is the beam attached solidly on the surface? What is attached on the other side of the spring?
A picture could speak volumes!

Picture

You can retrieve the current ModelViewMatrix (which contains the transform information) like so:


GLfloat matrix[16]; 
glGetFloatv (GL_MODELVIEW_MATRIX, matrix);

You can manipulate the matrix yourself (invert it etc) to keep a tab of where your items end up.