To be ohnest it’s rather a math question than OpenGL one but
I hope that there is a solution somewhere in OpenGL. It’s about
camera… I have 3 rotation angles - each about each axis. Let’s
call them Rx, Ry, Rz. I’ve also got a position of the camera PosX,
PosY, PosZ. Now, let’s say I’d like to set the cameras angles
in a way that camera would be facing a particular point (X, Y, Z).
I’ve made a math solution for this but there is too much
acos, atan and it’s hardly any good one. So meaby you know
some better ways of calculating these ANGLES?

If that’s not what you need then you need to google for Euler angles.

This should be simple, you don’t have roll, so that’s always zero (not enough info to specify this with a single vector), all you need is heading & pitch (probably rx and ry in typical OpenGL coordinates). You have a vector from (lookat_point - eye_pos
0. So it’s simple trig.

acos ((x, 0, z) . (x, y, z)) gives you pitch or rotation about x, make sure you normalize the vectors before the dot product.

atan2f with x and z should give you the heading or rotation about y, although you may have to mess with the signs to get the quadrants right.

The only thing you need to worry about next is multiplication order of heading and pitch, but I assume you have some library for this.

If you have some z up scheme instead of y up the same thing applies but with different axes being used in the math above.

Originally posted by dorbie:
[b].
acos ((x, 0, z) . (x, y, z)) gives you pitch or rotation about x, make sure you normalize the vectors before the dot product.

atan2f with x and z should give you the heading or rotation about y, although you may have to mess with the signs to get the quadrants right.

The only thing you need to worry about next is multiplication order of heading and pitch, but I assume you have some library for this.
[/b]

Yeah. I’ve made it this way but there are still some things I’ve forgot about (like normalizing vectors). OK. I’ll try it.
Thanx