The left camera, LC, the right camera, RC, and the object, O, form a triangle. This triangle is comprised of two right-angle triangles as shown below.

From basic trigonometry, it is known that and are the same as those in Figure 1. Using trigonometry, the following can be derived:
Therefore:
The following diagram shows the two camera views taken out from the first diagram for clarity. Think of each image as a grid, where the origin is the centre of the image.

is the width of the image in pixels. The terms and are the x-coordinates of the object in the left and right images, respectively. As an example, consider the left view. There are two right-angle triangles, both of which share the side . The smaller triangle has a top that goes up to the point. is also the top's length, as it is the x-coordinate where the centre is the origin. The larger triangle has a top that goes up to the end of the image. Using the smaller triangles in both views, we know the following using some basic trigonometry.
We negate as widths should be positive. Now consider the larger triangles. As they go up to the end of the image, the width of their tops are half of the image width, . More trigonometry ensues.
Equating equations (2) and (4), we get:
Similarly, equating equations (3) and (4), we get:
We're nearly there! Adding equations (5) and (6) gives:
Substituting (7) back into (1) gives us our final equation.