I try to found out, how to work this code.
public class UnPoint
{
public int X, Y;
public float x, y;
public float v;
public static float X_MIN = -1f;
public static float X_MAX = 1f;
public static float Y_MIN = 0f;
public static float Y_MAX = 1f;
public UnPoint(int XX, int YY, int w, int h)
{
X = XX;
Y = YY;
x = (X_MAX-X_MIN) / ( (float)(w-1) ) * ( (float)X ) + X_MIN;
y = (Y_MAX-Y_MIN)/((float)(h-1))*((float)((h-1) - Y)) + Y_MIN;
}
}
What is x, y? I think, that it is some kind of normalization. But I don't find type of this.
I'll be glad to any advice.
This code is normalizing a value XX
from the interval [0 w-1]
into the interval [-1 +1]
and a value YY
from the interval [0 h-1]
to the inverse location in the interval [0 1]
.
E.g. it can normalize screen coordinates from (0,0) in the upper left corner, to (w-1, h-1) in the lower right corner, so the left edge of the screen is X_MIN
(-1), the right edge of the screen is X_MAX
(+1), the top edge of the screen is Y_MAX
(1) and the bottom edge of the screen is Y_MIN
(0).