// Проверяет, что линия, соединяющая две вершины полигона, не пересекает его стороны bool clearPath(int v0, int v1) { int clockwise, anticlockwise, t0, t1; if (orientation()) { clockwise = 2; anticlockwise = 1; } else { clockwise = 1; anticlockwise = 2; } t0 = v0; t1 = v1; v0 = Math.Min(t0, t1); v1 = Math.Max(t0, t1); LineD line = new LineD(vert[v0], vert[v1]); var test = from v in Enumerable.Range(0, vert.Length) where (v > v0 && v < v1) select line.orientation(vert[v]); for (int v = 0; v < vert.Length; v++) { if (vert[v].X > Math.Min(vert[v0].X, vert[v1].X) && vert[v].Y > Math.Min(vert[v0].Y, vert[v1].Y) && vert[v].X < Math.Max(vert[v0].X, vert[v1].X) && vert[v].Y < Math.Max(vert[v0].Y, vert[v1].Y) && ((v < v0 && line.orientation(vert[v]) == clockwise) || (v > v0 && v < v1 && line.orientation(vert[v]) == anticlockwise) || (v > v1 && line.orientation(vert[v]) == clockwise))) { return(false); } } return(true); }