One-point perspective formula

A column of cubes

In the image, the length of the side of each cube is one unit. The dotted black line represents the negative side of the z axis. Given a vanishing point P(x, y) on the image plane, how do I calculate the distances between the horizontal and vertical blue lines? Another way to ask the same question is: how do I calculate the x and y coordinates of the unit marks on the z axis?

I've watched many videos on one-point perspective drawing, but none of them talk about the mathematical aspect of it. I've also read about a matrix multiplication method, but I don't quite understand it, and I wonder if there is a way to get my answer using just trigonometry and the given point P(x, y). Any help is greatly appreciated!

• You can use this link ( automotiveillustrations.com/tutorials/… ) as a reference. Picture 10 is the kind of drawing you want, and is pretty easy to find what kind of transforms you need to find the projection of a point. – N74 Jun 26 '17 at 19:49

If you have a 3D coordinate system with origin $(0, 0, 0)$ at your (dominant) eye, the picture plane at $z = d$, and the vanishing point at origin in your picture, then each 3D point $(x, y, z)$ can be trivially projected to your picture plane at $(x', y')$: $$\begin{array}{l} x' = x \frac{d}{z} \\ y' = y \frac{d}{z} \end{array}$$

This is not a trick. It is not an approximation either. If the coordinate systems and the location of the observer are defined this way, you do get the 2D-projected coordinates simply by multiplying them by $d / z$, where $d$ is the distance from the observer to the projection plane (picture), and $z$ is the 3D $z$-coordinate for that point. I've explained why at the beginning of this answer.

If you want the 3D origin to be on the picture plane, with your dominant eye at $(0, 0, -d)$, then $$\begin{array}{l} x' = x \frac{d}{z + d} \\ y' = y \frac{d}{z + d} \end{array}$$

If you want the 3D origin, and the vanishing point, to be at $( x_0 , y_0 )$ on the picture plane, and your eye is at $( x_0 , y_0 , -d )$, then $$\begin{array}{l} x' = x_0 + ( x - x_0 )\frac{d}{z + d} \\ y' = y_0 + ( y - y_0 )\frac{d}{z + d} \end{array}$$

The case where the eye is at $(0, 0, -d)$ but vanishing point at $( x_0 , y_0 )$ on the image plane, is a bit funny and somewhat more complicated, because the picture plane is skewed: it is not perpendicular to the line between the eye and the vanishing point $(0, 0, \infty)$. I haven't worked out the math for that case, because I've never needed to find out how to project an image that would be mostly viewed from the side.

Other projection models can be constructed from the same principles I outlined here, but the corresponding formulae are more complicated.

For example, two- and three-point perspectives can be modeled using a 3D coordinate system where origin is at the origin of the picture plane, but the 3D $x$ and $z$ axes (for two-point perspective), or $x$, $y$, and $z$ axes (for three-point perspective) are towards their respective vanishing points. The formulas for $x'$ and $y'$ are more complicated than above, because the 3D coordinate system is rotated compared to the 2D one.

(After all, vanishing points are nothing special or magical: any point infinitely far away is a vanishing point. When used as a geometric tool for perspective, we simply utilize the fact that all parallel lines meet at the same vanishing point. If you wanted to draw a picture of a quarter henge with say five monoliths, you could use five vanishing points, one for each monolith.)

Non-planar projections, for example projecting on a cylinder, are derived the same way using optics and linear algebra: simply put, by finding where the line between the eye and the detail we are interested in, intersects the projection surface.

Matrices are only used in this kind of math, because they let us write the operations needed in more concise form: in shorthand, in a way. In fact, if you can add, subtract, multiply, divide, and use up to three variables in a formula, you know enough math to start delving into descriptive geometry. If you then learn about vectors, matrices, and versors, you can quickly master the principles used in 3D graphics, ray tracing, and descriptive geometry applications in general.

• Thank you for your answer! Is it possible to determine the value of d in the case of the image in this question? I'm assuming that would correspond to the distance from the imaginary camera to the xy plane, but I'm not sure if that can be derived from the information given. – Auggie Jun 29 '17 at 4:38
• @Auggie: Yes, $d$ is the distance from camera/eye/observer to the image plane. No, there is no way to define $d$ from the information you have given; additional information is needed. For example, if you know that the horizontal field of view in the image is $\alpha = 114°$, and the image width is $W$, then $d = \frac{W}{2} \tan\left(\frac{\alpha}{2}\right) \approx 0.77 W$. – Nominal Animal Jun 29 '17 at 6:38

Using the fact that the columns of a transformation matrix are the images of the domain’s basis, we can immediately write down a matrix for the projection represented by the image: $$P=\begin{bmatrix}1&0&-\mu x_P&0\\0&1&-\mu y_P&0\\0&0&-\mu&1\end{bmatrix}.$$ The first two columns say that the vanishing points of the $x$- and $y$-axes are still at infinity (and that there’s no scaling in those directions), and the last column represents the origin’s image, which I’m assuming is the origin in the image’s coordinate system. The third column is the $z$-axis vanishing point, negated because we’re sighting “down” along the $z$-axis. It also includes a “foreshortening factor” $\mu$ which you’ll need to calibrate to get the desired spacing.

The image of any 3-D point is the product of $P$ and the point’s homogeneous coordinates: $$\begin{bmatrix}1&0&-\mu x_P&0\\0&1&-\mu y_P&0\\0&0&-\mu&1 \end{bmatrix}\begin{bmatrix}x\\y\\z\\1\end{bmatrix} = \begin{bmatrix}x-\mu x_Pz\\y-\mu y_Pz\\1-\mu z\end{bmatrix}.$$ These are the homogeneous coordinates of the image point, so we convert to Cartesian by dividing through by the last component. Thus, we have the mapping $$(x,y,z)\mapsto\left({x-\mu x_Pz\over1-\mu z},{y-\mu y_Pz\over1-\mu z}\right).\tag{*}$$ So, to find where the edges of the cubes in the stack should be, plug appropriate values of $x$, $y$ and $z$ into this formula.

For example, with the vanishing point at $(3,2)$ as pictured, we have $(1,0,z)\mapsto\left({1-3\mu z\over1-\mu z},{-2\mu z\over1-\mu z}\right)$. The images of the vertices will be at $z=0,-1,-2,-3,\dots$. This gives you the correct proportional spacing, but there’s still the parameter $\mu$ that you need to set to get a particular set of vertices. We can try to match your illustration: For $z=-1$, the image point is $\left({1+3\mu\over1+\mu},{2\mu\over1+\mu}\right)$. In your illustration, the $x$-coordinate of this vertex looks like it’s at about $1.4$, which corresponds to $\mu=0.25$. With this value for $\mu$, the unit tick marks along this line will be at $(1.4,0.4)$, $(1.67,0.67)$, $(1.86,0.86)$, $(2,1)$, and so on. We find the corresponding points along the upper right edge by mapping $(1,1,z)$ using the computed value of $\mu$: $(1.4,1.2)$, $(1.67,1.33)$, $(1.86,1.43)$, $(2,1.5)$, &c. The $x$-coordinates of these two sequences are identical, as one would expect.

• Thank you for your answer! As this is new material for me, can you please clarify what the letter μ stands for and how it is calculated? Rather than finding μ based on my graph, which is in turn based on visual guesses, what I'm trying to understand is what the value of μ should be, so that I can improve my graph and correctly represent perfect cubes. – Auggie Jun 26 '17 at 21:40
• @Auggie The vanishing point determines the proportional the spacing between successive cube edges in the stack, but the actual spacing is is controlled by the arbitrary factor $\mu$. You’ll have to play with it and pick a value that produces the result that looks best to you. It’s related to the focal distance of the imaginary camera that’s producing the image. Varying $\mu$ is akin to the overused cinematic trick of simultaneously zooming and trucking so that object in the foreground (the nearest cube face) remains the same but the background zooms in and out. – amd Jun 26 '17 at 22:32

Let $A(1,1)$ and $B(3,2)$.

We want to generate a graduation of points $P_n(a_n,b_n)$ on line segment $AB$ such that $P_0(a_0,b_0)$, and $P_1$ is an arbitrary point that will give the "arbitrary scale" (corresponding to factor $\mu$ in @amd 's very interesting answer). Let us consider that (based on what you have taken for your own figure)

$a_1=1.3$ and $b_1=1.2$

All this with a limit point that we can denote by $P_{\infty}(a_{\infty},b_{\infty})=B=(3,2).$

The coordinates of $P_{n+1}$ can be obtained from the coordinates of $P_{n}$ in the following recurrent way:

$$\tag{1}a_{n+1}=\dfrac{5a_n-3}{a_n+1} \ (a) \ \ \ \text{and} \ \ b_{n+1}=\dfrac{5b_n-2}{b_n} \ (b)$$

(thus $P_{2}=(1.54 ; 1.33), P_{3}=(1.83 ; 1.5),$ etc.

How formulas (1) (a) and (b) can be explained ? By preservation of cross ratio by projective transformations / perspectivities (http://www.cut-the-knot.org/pythagoras/Cross-Ratio.shtml).

Let us look at the case of the formula for the $a_n$: we just have to consider that what we look is the image of a real wall of cubes with their lower left corner at points $0,1,2,...$:

$$\begin{array}{cccc}a_0=1&a_1&a_2&a_{\infty}=3\\ \downarrow&\downarrow&\downarrow&\downarrow\\0&1&2&\infty\end{array}$$

Let us express the cross ratio preservation:

$$\dfrac{a_2-1}{a_2-a_1} \times \dfrac{3-a_1}{3-1}=\dfrac{2-0}{2-1} \times \dfrac{\infty-0}{\infty-1} \ \iff \ \dfrac{a_2-1}{a_2-a_1}=\dfrac{4}{3-a_1}$$

out of which one can deduce

$$a_{2}=\dfrac{5a_1-3}{a_1+1}$$

and more generaly, replacing $a_1$ by $a_n$ and $a_2$ by $a_{n+1}$, we get forula (1) (a). The proof of formula (1) (b) can be obtained from the very same computation based, in this case, on the preservation of cross ratio for :

$$\begin{array}{cccc}b_0=1&b_1&b_2&b_{\infty}=2\\ \downarrow&\downarrow&\downarrow&\downarrow\\0&1&2&\infty\end{array}$$

• Thank you for your answer! The only thing I don't understand yet is why the point you referred to as P1 = (a1, b1) is an arbitrary point. In the image I provided, I chose that point to be P1 = (1.4, 1.2) because it "looked right" to the eye. Had I chosen P1 to be (2.5, 1.75), the front cube would have looked like a very deep box. Similarly, had I chosen P1 to be (1.1, 1.05), the front cube would have looked like a very thin box. What I'm trying to find out is the correct value of P1. Can that be calculated from what's given in the question, and if not, what variable is missing? – Auggie Jun 27 '17 at 18:41
• It is arbitrary in a rather small range, because, as you said it has to be compatible with a "good perception" of a cube and not a shoebox. But it is not possible to assign a precise value giving the good depth: taking 1.35 or 1.45 will provide a resutlt as "right looking" as 1.4. Maybe, I will add a drawing to my answer explaining why. – Jean Marie Jun 27 '17 at 18:52