1 using Microsoft.Xna.Framework;
5 readonly record
struct Triangle2D(Vector2 A, Vector2 B, Vector2 C)
7 public bool Contains(Vector2 point)
10 int halfPlaneAb = MathUtils.VectorOrientation(A, B, point);
11 int halfPlaneBc = MathUtils.VectorOrientation(B, C, point);
12 int halfPlaneCa = MathUtils.VectorOrientation(C, A, point);
16 bool allNonNegative = halfPlaneAb >= 0 && halfPlaneBc >= 0 && halfPlaneCa >= 0;
17 bool allNonPositive = halfPlaneAb <= 0 && halfPlaneBc <= 0 && halfPlaneCa <= 0;
19 return allNonNegative || allNonPositive;