Search code examples
cssmathperspective

Determine the visual size of an object at a given distance from origin (using perspective)


Let's say we have a square, 50 pixels wide. And the -webkit-perspective is 1000px*.

What is the formula to determine how big the square will appear to be at a given distance from the viewer (the width it will actually appear to be on screen)?

* This means that the viewer's position is 1000px from the z=0 point.


Solution

  • The angular width of a square 50 units wide, when seen from a distance of x units, is 2 atan(25/x) (in radians).