Possible Duplicate:
Mapping coordinates from plane given by normal vector to XY plane
How is it possible to get the screen position of a dot, which is located in the 3D space?
The position of the camera is 0,0,0 and it isn’t rotated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Depends on your type of projection.
A standard perspective projection is:
That’ll give your a 90 degree field of view in both directions and assume you’re looking from (0, 0, 0) along z.
It’s normal to scale the geometry prior to projection to deal with the fact that the viewport isn’t often square. You’ll also notice that the results are undefined when z is 0 and will become problematic as z tends towards 0. It also maps both positive and negative z to screen when one of them should be behind the camera. Normally you’d trim geometry (or discard points) with z less than a certain threshold.
In terms of dots, also notice that (assuming you’re keeping positive z) if abs(x) > z or abs(y) > z then the dot is offscreen. If you move on to full geometry then you can use that observation to clip it at the screen edges, saving per-pixel tests.