# How to convert -1 to 1 coordinate back to screen coordinates?

Here is a question in which Questioner asks how to convert world coordinates to 1 to -1 coordinates like Opengl, I want to know how to do that in reverse, that given a coordinates between 1 and -1 (both x and y axis), how can i change it back to screen coordinates. i.e if my width and height is 1000, and given a coordinate (0,0), how can i change it to 500, 500, So that i can render it.

For this problem specifically:

screenX = ((glX + 1) / 2.0) * maxScreenX;
screenY = ((glY + 1) / 2.0) * maxScreenY;


In general, the solution for going from coordinate system A to coordinate system B is:

B = ((A - minA) / (maxA - minA)) * (maxB - minB) + minB;


For instance substituting into your example with B as screenX & A as glX, we'd get:

screenX = ((glX - minGlX) / (maxGlX - minGlX)) * (maxScreenX - minScreenX) + minScreenX;
screenX = ((glX - -1) / (1 - -1)) * (1000 - 0) + 0;
screenX = ((glX + 1) / 2) * 1000;

• Do you mean B(x, y) by B and A(x, y) by A ?
– user82860
Jun 6, 2016 at 16:06
• Sort of, but the min & max apply to each coordinate component separately. I've added an example showing how to substitute the coords in. Jun 6, 2016 at 16:38