//Is a point intersecting with a triangle? private void PointTriangle() { MyVector2 p = pointTrans.position.ToMyVector2(); MyVector2 t_p1 = t1_p1_trans.position.ToMyVector2(); MyVector2 t_p2 = t1_p2_trans.position.ToMyVector2(); MyVector2 t_p3 = t1_p3_trans.position.ToMyVector2(); Triangle2 t = new Triangle2(t_p1, t_p2, t_p3); bool isIntersecting = Intersections.PointTriangle(t, p, includeBorder: true); //Display //Gizmos.color = isIntersecting ? Color.red : Color.white; //Gizmos.DrawWireSphere(p.ToVector3(), 0.1f); //Gizmos.DrawLine(t.p1.ToVector3(), t.p2.ToVector3()); //Gizmos.DrawLine(t.p2.ToVector3(), t.p3.ToVector3()); //Gizmos.DrawLine(t.p3.ToVector3(), t.p1.ToVector3()); //With mesh to better see what's going on //Triangle TestAlgorithmsHelpMethods.DisplayTriangleMesh(t_p1, t_p2, t_p3, Color.white); //Point Color pointColor = isIntersecting ? Color.red : Color.white; TestAlgorithmsHelpMethods.DisplayCircleMesh(p, 1f, 20, pointColor); }