Caculate roation angles in 3D-Space

27 Views Asked by At

I am given a vector n = (u,v,w) that is oriented in 3d space. No I have to rotate the normal vector, so that it is oriented in the same direction as the z-axis. The problem is, that i can only rotate in steps arround the x,y and z axis.

How would i calculate the angles i have to rotate?

1

There are 1 best solutions below

0
On BEST ANSWER

Only two rotations, about the $x$ axis, then about the $y$ axis, or vice versa, are needed. When rotating about the $x$ axis, $x$ is fixed, while $y$ and $z$ vary. You want to bring the $y$ coordinate of the rotated vector to $0$. Hence, the angle of rotation is given by

$ \phi_x = \text{atan2}(w, v) $

And this rotation is counter-clockwise when the $x$ axis is pointing towards you.

After this rotation, the vector becomes $( u, 0, \sqrt{v^2 + w^2} ) $

Next, you rotate the vector about the $y$ axis. The want to bring the $x$ coordinate to $0$. The angle of rotation is

$ \phi_y = \text{atan2}(\sqrt{v^2 + w^2} , u ) $

And this rotation is clockwise when the $y$ axis is pointing towards you.

The final vector after these two rotations is $(0, 0, \sqrt{u^2 + v^2 + w^2})$