我试着找出,如何使用这段代码。
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;
}
}
什么是 x、y?我认为,这是某种正常化。但我找不到这种类型。
我很乐意接受任何建议。
此代码规范化从区间[0 w-1]
到区间[-1 +1]
XX
值,以及从区间[0 h-1]
YY
到区间[0 1]
中的反位置的值。
例如,它可以将屏幕坐标从左上角的 (0,0) 标准化到右下角的 (w-1, h-1),因此屏幕的左边缘是X_MIN
(-1),屏幕的右边缘是 X_MAX
(+1),屏幕的顶部边缘是 Y_MAX
(1),屏幕的下边缘是Y_MIN
(0)。