using Microsoft.Xna.Framework;

namespace Sledgemapper
{
    public static class Utils
    {
        private static float Sign(Point p1, Point p2, Point p3) { return (p1.X - p3.X) * (p2.Y - p3.Y) - (p2.X - p3.X) * (p1.Y - p3.Y); }

        public static bool PointInTri(Point pt, Point v1, Point v2, Point v3)
        {
            bool b1, b2, b3;
            b1 = Sign(pt, v1, v2) < 0.0f;
            b2 = Sign(pt, v2, v3) < 0.0f;
            b3 = Sign(pt, v3, v1) < 0.0f;
            return (b1 == b2) && (b2 == b3);
        }
    }
}