Closed form for x-ray projection of a cube on a plane

34 Views Asked by At

Imagine a cube of side $d$ positioned at $\mathbf{x}_0 = [x_0, y_0, z_0]$ in a 3-dimensional space. Consider a scan plane $P$ with normal vector $\mathbf{n} = [n_x, n_y, n_z]$ (like in the following figure). We are interested in finding the projection of the cube on the scan plane. The projection value at each point $\mathbf{p} = [x, y, z]$ on the plane is the length of the line segment going through $\mathbf{p}$ parallel to $\mathbf{n}$ and restricted inside the cube (quantity $l$ in the figure).

I am interested in finding a closed form solution for the problem.

Example Setup

What I have done so far:

I can find the intersection of the line passing through $\mathbf{p}$ and parallel to $\mathbf{n}$ with all 6 sides of the cube. This gives me 6 points in space. Then I check which ones of these 6 intersection points lie on the cube boundaries. At most two points do. The Euclidean distance of these two points is the solution. This solution works, but is not scalable for implementation; imagine trying to find this for millions of points on the scan plane. That's why I am looking for a closed form solution to make my implementation faster.