# Am I calculating perspective projection correctly?

If I have a point in world space: (wx, wy, wz)

and I have a centre of projection: (cx, cy, cz)

and I wanted to project that point using perspective projection

would my point on the screen be calculated by:

x = (cz * wx) / wz y = (cz * wy) / wz

I got this from this lecturer https://www.youtube.com/watch?v=VpNJbvZhNCQ I don't understand what he means by the variable 'd'. What would the variable 'd' be?

• Once you get into this, you're going to have to come to terms with homogeneous coordinates. Here is a nice introduction to projection. Nov 29, 2016 at 13:30

In the video you linked to, $d$ is just the distance from the eye to the image plane. To simplify things though, you can just set $d$ to 1, which is the usual case and causes it to disappear from the formulas.

Your formula for projection is a bit wrong but don't worry, projection is actually pretty simple.

$x_{Screen} = x_{World} / z_{World}\\ y_{Screen} = y_{World} / z_{World}$

If you want to move the center of projection, you can do so with a screen space coordinate, by modifying the formula to be this:

$x_{Screen} = x_{World} / z_{World} - x_{ScreenCenter}\\ y_{Screen} = y_{World} / z_{World} - y_{ScreenCenter}$

If you want to re-introduce the $d$ value to control the distance from the eye to the projection plane, you can use the formula below. Adjusting $d$ will make the camera look like it is zooming in or out. Again, you can just set $d$ to 1 though and not deal with it.

$x_{Screen} = d*x_{World} / z_{World} - x_{ScreenCenter}\\ y_{Screen} = d*y_{World} / z_{World} - y_{ScreenCenter}$