# Perspective geometry: How to put an item in a projection according to distance

I have the following image of a road

The image represents a road 100 meters long, as viewed from a camera 1 m high.

I want to place a car 50 meters ahead of me in the middle lane but I can't quite figure out how to calculate where to put it. I can calculate the expected width it will have using the view angle and then according to that figure out it's location on the road, but I'm hoping there's something simpler.

Example:

Any tips on how to do this?

Your road is 100 meters long and you want to find 50 metres, so we are basically looking for a way to divide the road in half. That's quite easy. Just draw in the diagonals of a rectangle and they should intersect in the center, in perspective as well as in plan:

There is also a neat trick to divide the depth of a rectangle by projecting the divided width onto the diagonal and then to the depth, like this:

In your case, unfortunately, the center is positioned way off in the distance. The perspective must be rather distorted - the road almost ends in a point (I have taken the liberty to invert your image and continue the lines):

You could just shorten your road to change the perspective, but you could also look into constructing it more precisely from a plan and an elevation. It is good practice i guess, but if you need a fast result it might be easiest to use some free 3D software like SketchUp or Blender to make a basic sketch.

If you can calculate it, you understand the scenario. That makes to you possible as well draw it. In Illustrator or Inkscape you can have any scaling without losing the accuracy. I have constructed an example, how apparent heights ( actually distances to the horizon line) can be drawn:

1. The observer

2. the place of the apparent drawing paper. All heights are marked here. The top of the vertical blue line is the top edge of the paper and the bottom end of the same line is the bottom of the paper.

3. a line to the horizon

4. the end of your lane

5. a simple object

The next image is a construction of the heights. The widths are quessed except the object 5 is drawn like it were rectangular and parallel with the lane. Thats why the edges are directed to the same escape point than the sides of the lane.

For exact widths you need a top view projection that you use to measure the apparent widths in the same way as I measured the heights.

This all is a very old theory that was in wide use before the year 1500. If you want to do it easily, goto 3D. Even free SketcUP can help yo create realistical perspectives. There's no urgent need to construct complex 3D models. You can place there only coarse mock-ups and then make a careful illustration over the SketcUP screenshot. In addition very rich selection of things (everyday stuff, buildings, animals....) is freely downloadable straight into your scene from SketchUP's 3D warehouse.

In Illustrator there's the Perspective Grid tool which is handy if you work in 2D, want consistent looking perspective but are not especially interested to make too many measurements from different projections. It's as accurate as measurements, if you adjust it properly (tricky!!!!) to yor scene and have some calibration objects that have realistic 2D dimensions.

This is the principle without any scale. You are in point A. The apparent place of your image B is unknown, So is C, where the lane edges disappear from the image. The only known distance is 100 meters from A to D. Unfortunately that's not enough to reconstruct your case, because your image has very low resolution. We cannot reliably decide how wide the far end of your whole track is in the image.

Lets assume you can measure it better. Let you have got the far end of your whole 3 lane track have width T (pixels, millimeters or other units) in your image.

Then we can calculate the apparent distance of the image.

The apparent distance AB = T * (100m / the real width of the track)

We assume that your camera doesn't have any distortion.

If you can decide T, then you probably can mark the escape point, too by continuing the right and left edges of your track. They meet at the escape point and there's also your horizon.

Now we can calculate how much below the horizon is the apparent ground at 50m distance. The real altitude difference is 1m, as you told.

the altitude difference from the horizon to ground in the image is

= (1m/50m) * AB = 0,02 * (100m / the real width of the track) * T

Lets assume your T= 8 pixels and your total track width is 8 meters. Then the ground at 50m in front of you has altitude 2 pixels below the horizon in the image.

That's not very inspiring result. If the car happens to be 2m wide, its width in the image would be 4 pixels. If you work in photoshop, you have generously 3 smaller brush sizes to paint the details.

To have artistically interesting output you should consider to draw the car to much less distant position.

Simply:

• Make a rectangle with a horizontal line in the middle.
• Apply the perspective transform to have the rectangle overlap your road.
• The middle line in the rectangle with perspective is where your 50m line is.
• But what is "the perspective transform"? – Cai Jul 3 '17 at 19:55
• @cal Somewhere in `Edit>Transform` in Photoshop. `Tools>Transform>Perspective` in Gimp. All graphics editors have this. – xenoid Jul 3 '17 at 23:14
• To use this you should know how far is the place which corresponds the bottom of the image. Otherwise you cannot place the 50m marking. The distance of the bottom isn't zero because that would make the bottom infinitely wide. Unfortunately this heavy transforms are calculated often inaccurately. Draw a diameter to the rectangle and transform. If it stays straight, the result is usable. – user287001 Jul 4 '17 at 0:05
• @xenoid This would work but I prefer to draw the shape directly in it's correct location so it doesn't get distorted – Dotan Jul 4 '17 at 6:37
• @dotan This is independent of the shape you draw... this is just a way to create a guide showing you where to draw... – xenoid Jul 4 '17 at 9:18

You would need to set up a scale before the perspective projection. If you convert the known scale to the perspective, you can have markers for distance.

(This is not an accurate scale / just eyeballed)

• The thing is, the vertical distance between the 1,2M marks should be larger than that between the 2,3M marks and so on – Dotan Jul 3 '17 at 15:59
• Yeah if you set up an accurate scale, and then add the perspective projection, the marks will be accurate. My image is just an example, that scale is by no means accurate and I just picked a random projection. The goal was to show how, not provide a working model. The marks in my projection are varied in distance, It's just not a very deep projection. – Scott Jul 3 '17 at 16:09