How to rotate 3D vector and find its intersection with a fixed plane? Application
Let's say I have a camera pointing straight down mounted at a fixed x,y,z above a conveyor. The camera can rotate in x (up and down the conveyor) and y (side to side across the conveyor) but not z (axis pointing into the conveyor). As a part moves along the conveyor, I'd like to rotate the camera to different angles to capture photos of the part. My controller needs the points on the conveyor plane where a vector coming out of the camera's lens (let's call it the "camera vector") intersect the conveyor plane.
How do I find the intersection of a rotated 3D vector and a fixed plane?
Given variables
Constants: cam_x, cam_y, cam_z (height above conveyor), cam_rot_z=0, fixed plane
Variables: cam_rot_x, cam_rot_y
Rotation
From what I've found, I need to apply a rotation matrix to the camera vector. However, it sounds like I need to translate the origin over to the camera's origin before doing this.
Intersection
I think once I have the equation for the rotated camera vector and the (constant) equation for the plane, I can just use the equations from this question, correct?
I have not done linear algebra in over 10 years so I apologize if this is a stupid question. Thanks in advance!
 A: Let the position of the camera be the point $P_0 = (x_0, y_0, z_0)$ which is given.  The unrotated camera vector is
$u_0 = (0, 0, -1) $
Because the camera initially is pointing straight down.  Now the rotation of the camera is the composition of two rotations.  The first along the $x$ axis and the second along the $y$ axis.  Rotation about the $x$ axis is implementable using
$ P' = R_x(\theta_x) P $
and rotation about the $y$ axis is implementable using
$ Q' = R_y (\theta_y) Q $
where $P', Q'$ are the images of $P, Q$ respectively, and
$ R_x(\theta_x) = \begin{bmatrix} 1 && 0 && 0 \\ 0 && \cos(\theta_x) && - \sin (\theta_x) \\ 0 && \sin(\theta_x) && \cos(\theta_x) \end{bmatrix} $
$ R_y(\theta_y) = \begin{bmatrix} \cos(\theta_y) && 0 && \sin(\theta_y) \\ 0 && 1 && 0 \\ -\sin(\theta_y) && 0 && \cos(\theta_y) \end{bmatrix}$
The combined rotation is given by $R = R_x R_y $. The reason for this, is as follows:  The image (in world coordinates) of a point  specified in the $R_x$ frame is
$ P' = R_x P $
and the image of a point $Q$, specified in the frame $R_y$ in the parent frame (which is the $R_x$ frame) is
$Q' = R_y Q $
So now, by chaining, we have $Q' = P$, hence
$P' = R_x R_y Q $
So what remains is to find the product $R_x R_y$, and this is given by
$R = R_x R_y = \begin{bmatrix} \cos(\theta_y) && 0 && \sin(\theta_y) \\
\sin(\theta_x) \sin(\theta_y) && \cos(\theta_x) && - \sin(\theta_x) \cos(\theta_y) \\ - \cos(\theta_x)\sin(\theta_y) && \sin(\theta_x) && \cos(\theta_x) \cos(\theta_y) \end{bmatrix}$
Now the parametric equation of the camera ray is
$ P(t) = P_0 + t R u_0 $
and one can intersect this line with any plane, by plugging in the above expression in the equation of the plane which takes the form
$ N \cdot (r -r_0) = 0 $
Where $N$ is the normal vector to the plane, and $r_0$ is a point that the plane passes through.
