How to convert from one co-ordinate system to another (graphics)

Posted by Dororo on Stack Overflow See other posts from Stack Overflow or by Dororo
Published on 2011-06-22T23:45:06Z Indexed on 2011/06/23 0:22 UTC
Read the original article Hit count: 123

I've been having issues with this for a little while now. I feel like I should know this but I can't for the life of me remember.

How can I map the screen pixels to their respective 'graphical' x,y positions? The co-ordinate systems have been configured to start at the bottom left (0,0) and increase to the top-right.

I want to be able to zoom, so I know that I need to configure the zoom distance into the answer.

Screen
|\          Some Quad
| \--------|\Qx
|  \    Z  | \
|   \       \|Qy
 \  |
Sx\ |Sy
   \|

I want to know which pixels on my screen will have the quad on it. Obviously as Z decreases, the quad will occupy more of the screen, and as Z increases it will occupy less, but how exactly are these calculated?

Thanks for any help.

© Stack Overflow or respective owner

Related posts about graphics

Related posts about coordinate-systems