# Intersection of camera ray and 3D plane

Suppose we have a camera in 3D space and want to know where a ray emanating from a selected pixel intersects with a 3D plane. To solve this you’ll need to know the camera’s intrinsic properties (eg. focal length). It’s handy if you have the commonly used 3×3 camera intrinsic matrix available(usually from calibration), which allows you to convert from image points to normalised points as follows:

$\mathbf{p_{norm}} = K^{-1}\mathbf{p}$

where, K is the 3×3 intrinsic matrix and p are the image points, expressed as a 3×1 matrix of homogeneous points. The normalisation does the following:

• moves the origin (0,0) to the centre (or close to) of the image
• focal length becomes 1 unit

Using normalised image points, our problem can be illustrated as shown below, where $\left(x_i,\,y_i\right)$ are the normalised image points.

A ray coming from the camera can be described by a line vector. The line vector is just a vector from the origin (0,0,0) to the normalised image point in 3D space, the vector is just $\left(x_i,\, y_i,\, 1\right)$.  To fully describe the line, we write it in parametric form and introduce the variable t:

$Ray(t) = \left(x_{i}t,\,y_{i}t,\,t\right)$

Note: $x_{i}$ and $y_{i}$ are constants

Now a 3D plane in space (of infinite size) can be described by the plane equation:

Ax + By + Cy + D = 0

Combining the line and plane equation and solving for t gives:

$Ax_{i}t + By_{i}t + Ct + D = 0$

$t =\frac{-D}{Ax_{i} + By_{i} + C}$

Substitute t back into Ray(t) to find the 3D point of intersection.