2014-02-27 15 views
0

我试图找出,如何工作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; 
    } 
} 

什么是X,Y?我认为,这是一种正常化。但我没有找到这种类型。

我很乐意提供任何建议。

回答

2

此代码被从间隔[0 w-1]归一化值XX入间隔[-1 +1]和从间隔[0 h-1]到逆位置在间隔[0 1]YY

E.g.它可以将屏幕坐标从左上角的(0,0)标准化为右下角的(w-1,h-1),因此屏幕的左边缘为X_MIN(-1),右边缘屏幕的顶边是X_MAX(+1),屏幕的顶边是Y_MAX(1),屏幕的底边是Y_MIN(0)。

+0

谢谢你的回答。 – Jordan

相关问题