示例#1
0
文件: Polygon.cs 项目: Anovi-Soft/KGG
 public static Polygon Intersection(Polygon a, Polygon b)
 {
     b.points.Add(b.points.First());
     for (int i = 0; i < b.points.Count - 1; i++)
         a = Intersection(a, b.points[i], b.points[i + 1]);
     return a; 
 }
示例#2
0
文件: Polygon.cs 项目: Anovi-Soft/KGG
 public static Polygon Intersection(Polygon a, Vector b1, Vector b2)
 {
     List<Vector> result = new List<Vector>();
     a.points.Add(a.points.Last());
     for (int i = 0; i < a.points.Count - 1; i++)
     {
         Vector start = a.points[i];
         Vector end = a.points[i + 1];
         bool s = Vector.PlacePoint(b1, b2, start) >= 0;
         bool e = Vector.PlacePoint(b1, b2, end) >= 0;
         if (s)
             result.Add(start);
         if (s ^ e)
             result.Add(Vector.CrossingPoint(start, end, b1, b2));
     }
     return new Polygon(result);
 }