DistancePointToLineSegment() static private method

Determine the distance from the specified point to the line segment.
static private DistancePointToLineSegment ( Vector2 point, Vector2 a, Vector2 b ) : float
point Vector2
a Vector2
b Vector2
return float
Esempio n. 1
0
    public static float DistanceToRectangle(Vector2[] screenPoints, Vector2 mousePos)
    {
        bool flag = false;
        int  val  = 4;

        for (int i = 0; i < 5; i++)
        {
            Vector3 vector  = screenPoints[NGUIMath.RepeatIndex(i, 4)];
            Vector3 vector2 = screenPoints[NGUIMath.RepeatIndex(val, 4)];
            if (vector.y > mousePos.y != vector2.y > mousePos.y && mousePos.x < (vector2.x - vector.x) * (mousePos.y - vector.y) / (vector2.y - vector.y) + vector.x)
            {
                flag = !flag;
            }
            val = i;
        }
        if (!flag)
        {
            float num = -1f;
            for (int j = 0; j < 4; j++)
            {
                Vector3 v    = screenPoints[j];
                Vector3 v2   = screenPoints[NGUIMath.RepeatIndex(j + 1, 4)];
                float   num2 = NGUIMath.DistancePointToLineSegment(mousePos, v, v2);
                if (num2 < num || num < 0f)
                {
                    num = num2;
                }
            }
            return(num);
        }
        return(0f);
    }
Esempio n. 2
0
 public unsafe static long $Invoke17(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(NGUIMath.DistancePointToLineSegment(*(*(IntPtr *)args), *(*(IntPtr *)(args + 1)), *(*(IntPtr *)(args + 2)))));
 }