Example #1
0
        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);
                }
            }
        }
Example #2
0
 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;
 }