Andy Chmilenko's Blog

# video game programming

## Forced Perspective with 3D Graphics

Submitted by Lanowen on Sun, 05/24/2015 - 02:15

A friend asked me about this problem, on how to calculate the distance an object needs to be from the camera to appear a certain height on the screen.

###
Easy Solution:

The solution is simpler when dealing with an object centered in the in the screen where a right angle can be created from the camera to the object.

Fig. 1: right angle triangle diagram.

$\figLbl{1}{tanSol}$

Solving the triangle in \ref{fig:tanSol}:

\begin{equation}

\tan{\left( \frac{\theta}{2} \right)} = \frac{h}{2d}

\label{eq:tanTriangle}

\end{equation}