Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Normalized Device Coordinates

I'm writing a library that deals with 2D graphical shapes.

I'm just wondering why should my coordinate system range from [-1, 1] for both the x and y axis enter image description here

instead of [0, width] for x and [0, height] for y ? enter image description here

I went for the latter system because I felt it was straight forward to implement.

like image 695
Jonas Avatar asked Mar 28 '13 22:03

Jonas


People also ask

How do you normalize pixel coordinates?

YNorm = Y / height; Where X and Y are the original pixel coordinates, width and height are the width and height of the Digitizer window, and xNorm and yNorm are the normalized X and Y coordinates for the pixel. If the width and height are not identical, then the normalized scaling in X and Y will be different.

How world coordinate system is converted to device coordinate system?

Window to Viewport Transformation is the process of transforming 2D world-coordinate objects to device coordinates. Objects inside the world or clipping window are mapped to the viewport which is the area on the screen where world coordinates are mapped to be displayed.

Is clip space same as NDC?

No, clip space and NDC space are not the same thing. Clip space is actually one step away from NDC, all coordinates are divided by Clip. W to produce NDC. Anything outside of the range [-1,1] in resulting NDC space corresponds to a point that is outside of the clipping volume.

What are clip space coordinates?

The clip coordinate system is a homogeneous coordinate system in the graphics pipeline that is used for clipping. In OpenGL, clip coordinates are positioned in the pipeline just after view coordinates and just before normalized device coordinates (NDC).


1 Answers

From Jim Blinn's A Trip Down The Graphics Pipeline, p. 138.

Let's start with what might at first seem the simplest transformation: normalized device coordinates to pixel space. The transform is

s_x * X_NDC + d_x = X_pixel
s_y * Y_NDC + d_y = Y_pixel

A user/programmer does all screen design in NDC. There are three nasty realities of the hardware that NDC hides from us:

  1. The actual number of pixels in x and y.

  2. Non-uniform pixel spacing in x and y.

  3. Up versus down for the Y coordinate. The NDC-to-pixel transformation will invert Y if necessary so that Y in NDC points up.

...

s_x = ( N_x - epsilon ) / 2
d_x = ( N_x - epsilon ) / 2

s_y = ( N_y - epsilon ) / (-2*a)
d_y = ( N_y - epsilon ) / 2

epsilon = .001
a = N_y/N_x  (physical screen aspect ratio)
like image 117
luser droog Avatar answered Sep 27 '22 19:09

luser droog