Here is my problem. I have to move a torus along a circular trajectory on a bicubic surface.
However the vertical axis of the torus must be aligned with the surface normal at the given point Moreover the torus must face it's circular trajectory.
To manage this i took the normal vector and the Oy vector, made a cross and a dot product to find the angle i need and the axis to rotate around, it works. To manage the 2nd part, i took the actual coordinates of the torus, the next ones on the circular trajectory, made a vector, and did the same as previously described to found the angle and the axis, it works.
My problem is, i must apply the two rotations simultaneously and i can't find a way to do this. I tryed to Push/Pop Matrix i every possible way but i can't find a way out of this one. So i'm back to this...
glPushMatrix();
glTranslatef(pp -> x, pp ->y , pp ->z);
glRotatef(*angledegree, vecortho -> x, vecortho -> y, vecortho -> z);
glRotatef(*angledegreetang, tang -> x, tang -> y, tang -> z);
tore(0.1, 0.3, 6, 4, 1);
repere(0.6);
glPopMatrix();
Any ideas? Sorry to bother you, it must be simple i think, but i don't see it. The first rotation always bugs the next one, whatever the order. vecortho is the axis vector computed from the surface normal and Oy. tang is the vector computed with my trajectory vector and Ox.