So, what do you expect to happen when your direction vector gets very close to your up vector? It seems to me that you may be causing this anomaly by your preconditions of fixing your up vector while allowing your direction vector to float.

If you’re just trying to construct a viewing transform, don’t do it that way. Just use gluLookAt, or code up the equivalent yourself. See this for more details. Look ma, no euler angles!

But yes, if you really want to do the euler angles thing, it’s of course possible. Pick up a graphics book like Foley and van Dam, IIRC. You rotate the vector into coordinate planes and note the angles.

Normalize vector V to get T with coordinates (q,r,s). I can tell you how to rotate the X unit vector (1,0,0) to T. First rotate XU about the Y axis by the angle -arcsin(s). Call this intermediate vector P. Then rotate P around the Z axis by the angle atan2(r,q). That’s all there is to it. You can use glRotates to do this graphically, or rotation matrices to do it mathematically (i.e. matrix multiplication). Does that answer your question?

I have the same question, I have a vector from the origin to a point. From (0,0,0) to (10,20,18).
I draw an arrow in the origin pointing like the x-axis. now I want to move the to the endpoint of my vector and rotate him so that it’s pointing the same way as the vector (gltranslate and glrotate).
How can I calculate the angles needed?

Normalize your vector (10,20,18). Now, pick an axis vector (e.g. 0,0,1), dot product to get the angle to that axis, subtract off that component. Now, repeat for another axis.

Sounds like you guys want someone to do your homework for you? Where are you with your graphics? For starters, can you display a unit vector pointing down the X axis? If so, post a screen capture and your code. Show us that you have done some work and are willing to do more. You’ll get more help from me that way.