Пример #1
0
    public static bool IsInTriangle(Vector3 point, Vector3 A, Vector3 B, Vector3 C)
    {
        Vector2 pa = new Vector2(A.x - point.x, A.z - point.z);
        Vector2 pb = new Vector2(B.x - point.x, B.z - point.z);
        Vector2 pc = new Vector2(C.x - point.x, C.z - point.z);
        float   t1 = XUtility.Cross(pa, pb);
        float   t2 = XUtility.Cross(pb, pc);
        float   t3 = XUtility.Cross(pc, pa);

        return(t1 * t2 >= 0 && t1 * t3 >= 0);
    }