# Applying Rotation Matrix to Rotate Point (2,4,4) wrt y onto X-Y Plane

My linear algebra is a little rusty. Given an arbitrary point P(x,y,z), how do I determine the theta needed to apply a rotation matrix that will rotate the point onto the X-Y plane, with respect to Y? More specifically, how do I determine the theta when the vector is outside of the XZ plane? I know how to solve for the direction cosine gamma, the angle between the vector terminating at the point P, and the +Z axis.

It must be a fundamental misunderstanding of the rotation, but when trying to apply the rotation matrix Ry(theta) to the point (2,4,4), I keep ending up with a non-zero z' value. I have looked at many references and videos, and there is just something I am not getting about this particular rotation.

For the point (2,4,4), I found the direction angle gamma, measured from the +z axis, to be 35.26, and my initial thought was that the theta to rotate through, about the y-axis, should be 90-gamma, or 54.74. After applying the rotation matrix, the z-component of the rotated point should be z'= -xsin(theta)+zcos(theta), but this yields a non-zero z'. If the vector was truly rotated down onto the XY plane, this value should be zero.

Where am I going wrong?

Thank you

• Is the rotated point $(2\sqrt{5}, 4, 0)$ ? – Aritra Das Apr 20 '16 at 5:46
• The direction cosine is measured in the plane defined by $P$ and the $z$-axis, but you need the angle of $P$’s projection onto the $xz$-plane (measured in that plane) instead. – amd Apr 20 '16 at 8:23

If I understand correctly, you’d like to rotate the given point about the $y$-axis to bring it onto the $xy$-plane. There are two such rotations, so I’m going to assume that you want to end up with $x\ge 0$.
Considering $P$ as a vector, the rotation will leave the vector’s $y$-component fixed while rotating its $xz$-component. The resulting point is clearly $(\sqrt{x^2+z^2},y,0)$, but if you want the rotation angle or matrix, then read on.
If the point is not on the $y$-axis, then the problem reduces to finding the 2-D transformation in the $xz$-plane that will rotate $(x,z)$ onto the positive $x$-axis. When viewed from the positive $y$-axis, this will be a $counterclockwise$ rotation through an angle of $\theta$, where $\tan\theta=z/x$. The usual 2-D rotation matrix does the trick, although the sign of the angle must be flipped because the $x$-and $z$-axes form a left-handed coordinate system. Expanded out to three dimensions, this becomes $$R=\pmatrix{\cos\theta & 0 & \sin\theta \\ 0 & 1 & 0 \\ -\sin\theta & 0 & \cos\theta} =\pmatrix{{x\over\sqrt{x^2+z^z}} & 0 & {z\over\sqrt{x^2+z^2}} \\ 0 & 1 & 0 \\ -{z\over\sqrt{x^2+z^2}} & 0 & {x\over\sqrt{x^2+z^2}}}.$$ You can check that this gives the expected result when applied to $P$.
For $P=(2,4,4)$, we get $$R=\pmatrix{\frac1{\sqrt5} & 0 & \frac2{\sqrt5} \\ 0 & 1 & 0 \\ -\frac2{\sqrt5} & 0 & \frac1{\sqrt5}}$$ and the resulting point is $(2\sqrt5,4,0)$.