public void Find() { double ed_curr = -1; double ed_next = -1; for (int i = 0; i < iterator_plane.Count && ed_curr < 0; i++) { ed_curr = Plane2dExt.Расширенное_расстояние(iterator_plane.Plane(0), iterator_point.Point(0)); ed_next = Plane2dExt.Расширенное_расстояние(iterator_plane.Plane(0), iterator_point.Point(1)); int k; if (ed_curr > ed_next) k = 1; else { ed_curr = ed_next; ed_next = Plane2dExt.Расширенное_расстояние(iterator_plane.Plane(0), iterator_point.Point(-1)); k = -1; } while (ed_curr >= 0 && ed_curr > ed_next) { iterator_point.Move(k); ed_curr = ed_next; ed_next = Plane2dExt.Расширенное_расстояние(iterator_plane.Plane(0), iterator_point.Point(0)); } if (ed_curr < 0) iterator_plane.Move(1); } if (ed_curr < 0) { Polygon2d.Iterator t = iterator_plane; iterator_plane = iterator_point; iterator_point = t; for (int i = 0; i < iterator_plane.Count && ed_curr < 0; i++) { ed_curr = Plane2dExt.Расширенное_расстояние(iterator_plane.Plane(0), iterator_point.Point(0)); ed_next = Plane2dExt.Расширенное_расстояние(iterator_plane.Plane(0), iterator_point.Point(1)); int k; if (ed_curr > ed_next) k = 1; else { ed_curr = ed_next; ed_next = Plane2dExt.Расширенное_расстояние(iterator_plane.Plane(0), iterator_point.Point(-1)); k = -1; iterator_point.Move(1); } while (ed_curr >= 0 && ed_curr > ed_next) { iterator_point.Move(k); ed_curr = ed_next; ed_next = Plane2dExt.Расширенное_расстояние(iterator_plane.Plane(0), iterator_point.Point(0)); } if (ed_curr < 0) iterator_plane.Move(1); } } }
public static bool IsRightPolygon(this Polygon2d polygon) { Polygon2d.Iterator iterator; iterator = new Polygon2d.Iterator(0, polygon, 0); bool is_right_polygon = true; for (int i = 0; i < iterator.Polygon.Count && is_right_polygon; i++) is_right_polygon = Plane2dExt.Расширенное_расстояние(iterator.Plane(i), iterator.Point(i + 2)) < 0; return is_right_polygon; }
public static bool IsContain(this Polygon2d polygon, Point2d point) { if (polygon.Count <= 1) return false; bool is_contain = true; Polygon2d.Iterator iterator = new Polygon2d.Iterator(0, polygon, 0); for (int i = 0; i < iterator.Polygon.Count && is_contain; i++) is_contain = Plane2dExt.Расширенное_расстояние(iterator.Plane(i), point) <= 0; return is_contain; }
// Получить разделяющие для объекта, заданного номером. // TODO: Переделать. public System.Collections.Generic.List<Plane2d> GetPlanes(int index) { System.Collections.Generic.List<Plane2d> res = new System.Collections.Generic.List<Plane2d>(); int k=4*polygons.Length; for(int i=0; i<polygons.Length-1;i++) for (int j = i + 1; j < polygons.Length; j++) { if (index == i || index == j) { Polygon2d.Iterator iti = new Polygon2d.Iterator((int)Gs[k][0], polygons[(int)Gs[k][0]], (int)Gs[k][2]); res.Add(iti.Plane(0)); } k++; } return res; }