コード例 #1
0
        public bool IsInTriangle(FixedVector2 p)
        {
            RecalculateDirectionalVectors();
            FixedVector2 ap    = a.GetDirectionTo(p);
            FixedVector2 bp    = b.GetDirectionTo(p);
            FixedVector2 cp    = b.GetDirectionTo(p);
            Fixed        bpXab = FixedVector2.PseudoscalarMultiplication(bp, ab);
            Fixed        cpXbc = FixedVector2.PseudoscalarMultiplication(cp, bc);
            Fixed        apXca = FixedVector2.PseudoscalarMultiplication(ap, ca);

            //this return means that sign of the pseudoscalar multiplications is equal
            return
                (apXca.IsZero() || bpXab.IsZero() || cpXbc.IsZero()
                 ||
                 (apXca.IsNegative() == bpXab.IsNegative() && apXca.IsNegative() == cpXbc.IsNegative()));
        }