How to calculate A's position based on world space?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to calculate A's position based on world space?

Ususuus
The problem comes from right the beginning when i started learning opengl, i just bypassed it, by translate and rotate several times...I think it's time to get it done in the right way.

the question is:  ( not real code, just describe my question)

for example, my body was placed in world space, my arm's position is A, my thumb 's position is B, relative to arm A, i want to know B's position relative to world space.

gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();

gl.glTranslatef(PostionA.xyz);
gl.glRotatef(PostionA.angleY, 1f, 0f, 0f);
gl.glRotatef(PostionA.angleX, 0f, 1f, 0f);

gl.glTranslatef(PostionB.xyz);
gl.glRotatef(PostionB.angleY, 1f, 0f, 0f);
gl.glRotatef(PostionB.angleX, 0f, 1f, 0f);

how do i get "Position B's xyz and x,y,z angle" , relative to world space.