예제 #1
0
    public static LineSituation IsBetween(Vector2 left, Vector2 target, Vector2 right)          // 3 lines start from the same point
    {
        Vector2 leftPerpendicular = SMath.GetPerpendicular2(left, true);

        if (Vector2.Dot(leftPerpendicular, target) < 0)                 // to the right of left line
        {
            Vector2 rightPerpendicular = SMath.GetPerpendicular2(right, true);
            if (Vector2.Dot(rightPerpendicular, target) > 0)                    // to the left of right line
            {
                return(LineSituation.Between);
            }
            else                // to the right of the right line
            {
                return(LineSituation.OutRight);
            }
        }
        else            // to the left of left line
        {
            return(LineSituation.OutLeft);
        }
    }