# distance to projection plane and coordinates per pixel

## Recommended Posts

Ewr    122
How can I get the distance from a point p to the projection plane? Is there any way to calculate the numbers of pixels per world coordinate unit in the screen x-y coordinate system?

##### Share on other sites
Well if point p is in camera or eye coordinates then I think the distance from p to the near projection plane would be the z-component of p minus the near projection plane distance.

I'm not sure exactly what your asking in your second question though. I can give you a formula for finding near projection plane coordinates based on camera coordinates.

projection plane x = (N * p.x)/-p.z
projection plane y = (N * p.y)/-p.z

Where N is the near projection plane distance I was talking about in the answer to the first part of your question, it's the second to last parameter in gluPerspective or glFrustum. I use -p.z because p.z is negative in camera coordinates anyway and I just need the absolute value for z. The larger the value of z or the greater the distance from the camera, the smaller the value of x and y on the projection plane aka perspective foreshortening. There is still another step before these are screen coordinates though, mainly how you called glViewport.

##### Share on other sites
Ewr    122
P is the view point...

Im not sure what the second question mean, it's a value I need to implement a algorithm, it's described "the number of pixels per world coordinate unit in the screen x-y coordinate system."