示例#1
0
 public static int pointInPolygon(Point a, Polygon p)
 {
     int parity = 0;
         for (int i = 0; i < p.size(); i++, p.advance((int)Clock.CLOCKWISE))
         {
             Edge e = p.edge();
             int result = edgeType(a, e);
             if (result == (int)EdgePozition.TOUCHING)
                 return (int)PointToFigurePozition.BOUNDARY;
             if (result == (int)EdgePozition.CROSSING)
                 parity = 1 - parity;
         }
         return ((parity != 0) ? (int)PointToFigurePozition.INSIDE : (int)PointToFigurePozition.OUTSIDE);
 }
示例#2
0
 public Polygon(Polygon p)
 {
     _size = p._size;
         if (_size == 0)
             _v = null;
         else
         {
             _v = new Vertex(p.point());
             for (int i = 1; i < _size; i++)
             {
                 p.advance((int)Clock.CLOCKWISE);
                 _v = _v.insert(new Vertex(p.point()));
             }
             p.advance((int)Clock.CLOCKWISE);
             _v = _v.cw();
         }
 }