What path should train tracks follow to appear parallel all the way to the horizon?

Solution 1:

Assuming that something looks of the same size to you if it takes up the same angle of view, the tracks should start at your locations and go radially outwards in straight lines. The angle between them determines the aparent distance.


If we assume that your eye is positioned some distance above the ground, then its a bit more complicated. Your region of "constant angle of view" can be described by a cone. The tracks then have to go along the intersection of this view-cone and the ground plane. This is a conic section, in our case it gives a hyperbola.

The arrow points in the direction of view.


If we keep the assumption that "same apparent size" = "same angle of view", then this implies that the problem can have no translational symmetry, because every view point and view direction needs a different cone to intersect with the ground.

Solution 2:

The answer depends critically on what you mean by “appear parallel.” If it’s that the visual angle made by the two rails is constant, then we’re basically talking about a projection onto a sphere, in which case the rails are hyperbolic as explained in M. Winter’s answer. On the other hand, if you mean that the lines are parallel on a perspective projection such as the image created by the usual pinhole camera model, then the rails are a pair of intersecting straight lines, as I’ll explain below.

Projective transformations map straight lines to straight lines, so your guess is correct, assuming that the rails lie on a common world plane—the ground plane. The projection induces a homography $\mathtt H$ between the ground and image planes. If a line on the ground plane is represented by the homogeneous vector $\mathbf l$, then its image is the line $\mathbf l'=\mathtt H^{-T}\mathbf l$, and so the line on the ground plane that corresponds to a line $\mathbf l'$ in the image is $\mathtt H^T\mathbf l'$.

Actually, a line in the image back-projects to a plane in the world. If the curves in the world that project onto a pair of parallel lines in the image aren’t constrained to be coplanar, then they must nevertheless lie on the two planes that correspond to the image lines. If the projection matrix is $\mathtt P$, then the plane that corresponds to a line $\mathbf l'$ in the image is $\mathbf\pi=\mathtt P^T\mathbf l'$. Geometrically, there is a star of planes through the camera center, and the three rows of $\mathtt P$ are a basis for this star. $\mathtt P^T\mathbf l'$ is a linear combination of these basis planes that contains the camera center and $\mathbf l'$. If the world curves—the “rails”—are coplanar, this gives another way to recover them: intersect $\mathbf\pi$ with the ground plane.

For example, let’s take a fairly standard setup of the camera at the origin looking along the $z$-axis toward the image plane $z=1$. For this setup $\mathtt P = [\mathtt I_3\mid 0]$. A line $ax+by+c=0$ in the image back-projects to the world plane $ax+by+cz=0$. If we take $y=-1$ as the ground plane, their intersection is the line $ax+cz-b=0$ in that plane. A straightforward calculation, which I won’t include here, produces $$\mathtt H = \begin{bmatrix}1&0&0\\0&0&-1\\0&1&0\end{bmatrix}$$ for the matrix of the homography between these ground and image planes. Using the formula from the top, the line $ax+by+c=0$ in the image then corresponds to the line $\mathtt H^T(a,b,c)^T=(a,c,-b)^T$, i.e., the line $ax+cz-b=0$ as computed previously. The lines $x=\pm h$ therefore correspond to $x=\pm hz$ on the ground. This is a pair of lines that intersect directly below the view point. The angle between them depends of course on their apparent separation in the image.

You raise an interesting follow-up question in various comments: what happens when the view point moves? Moving the camera to $\mathbf t = (t_x,t_y,t_z)^T$ while keeping the camera axis parallel to the $z$-axis and maintaining the same focal distance changes the projection matrix to $\mathtt P' = [\mathtt I_3 \mid -\mathbf t]$. The corresponding homography is $$\mathtt H' = \begin{bmatrix} 1 & 0 & -t_x \\ 0 & 0 & -(1+t_y) \\ 0 & 1 & -t_z \end{bmatrix}.$$ (As a sanity check, if $\mathbf t = 0$, this reduces to the original $\mathtt H$). Assuming that $t_y\ne1$, which would place the camera on the ground, the ground lines $x=\pm hz$ that gave us parallel lines in the original view are now projected to $$x= {t_x \mp h t_z \over 1+t_y}y \pm h.$$ These lines intersect at the point with homogeneous coordinates $$\left[{t_x \over 1+t_y} : 1 : {t_z \over 1+t_y}\right].$$ These projections of the lines will be parallel when the last coordinate is zero, i.e., when $t_z=0$. So, any movement in $z$—toward or away from the horizon—will destroy the visual parallelism of the lines. If the movement is purely in the $x$-$y$ plane, then the lines will still appear to be parallel, although their slope and separation will change.