Normalized Device Coordinates to window coordinates

Posted by okoman on Stack Overflow See other posts from Stack Overflow or by okoman
Published on 2011-01-02T14:27:31Z Indexed on 2011/01/02 14:54 UTC
Read the original article Hit count: 161

Filed under:
|
|

I just read some stuff about the theory behind 3d graphics. As I understand it, normalized device coordinates (NDC) are coordinates that describe a point in the interval from -1 to 1 on both the horizontal and vertical axis. On the other hand window coordinates describe a point somewhere between (0,0) and (width,height) of the window. So my formula to convert a point from the NDC coordinate system to the window system would be

xwin = width + xndc * 0.5 * width
ywin = height + ynfv * 0.5 * height

The problem now is that in the OpenGL documentation for glViewport there is an other formula:

xwin = ( xndc + 1 ) * width * 0.5 + x
ywin = ( yndc + 1 ) * height * 0.5 + y

Now I'm wondering what I am getting wrong. Especially I'm wondering what the additional "x" and "y" mean.

Hope the question isn't too "not programming related", but I thought somehow it is related to graphics programming.

© Stack Overflow or respective owner

Related posts about graphics

Related posts about 3d