2014-02-27 16 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

相關問題