public static bool IsPointInTriangle(Vector3d p, CadFace triangle, CadMesh mesh) { if (triangle.VList.Count < 3) { return(false); } Vector3d p0 = mesh.VertexStore[triangle.VList[0]].vector; Vector3d p1 = mesh.VertexStore[triangle.VList[1]].vector; Vector3d p2 = mesh.VertexStore[triangle.VList[2]].vector; Vector3d c1 = CadMath.CrossProduct(p, p0, p1); Vector3d c2 = CadMath.CrossProduct(p, p1, p2); Vector3d c3 = CadMath.CrossProduct(p, p2, p0); double ip12 = CadMath.InnerProduct(c1, c2); double ip13 = CadMath.InnerProduct(c1, c3); // When all corossProduct result's sign are same, Point is in triangle if (ip12 > 0 && ip13 > 0) { return(true); } return(false); }