0

I use Region for finding intersection of two paths (which created from two polygons).

GraphicsPath gp1 = new GraphicsPath();
gp1.AddPolygon(P);//P - array of points [first polygon]

Region d = new Region(gp1);

GraphicsPath gp2 = new GraphicsPath();
gp2.AddPolygon(P_);//P_ - array of points [second polygon]
d.Intersect(gp2);//founded intersection

How I can get points of intersection of Region d ?

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
Wolfgang
  • 254
  • 1
  • 5
  • 12

2 Answers2

1

I recommend using a polygon intersection library suited to this task.

Here is a most excellent one that is usable from C#

http://www.angusj.com/delphi/clipper.php

I am also sure there are many others written in C# too if that is required. Here is a SO Q&A on the topic:

How to intersect two polygons?

Community
  • 1
  • 1
Phil Martin
  • 466
  • 4
  • 4
1

Check whether graphicspath is intersecting or not by using

if(!d.IsEmpty(this.CreateGraphics())

{

RectangleF rectBound=d.GetBound(this.CreateGraphics());

Pointf intersectionPoint=new Pointf(rectBound.X+rectBound.Width/2,rectBound.Y+rectBound.Height/2);

}
Baby Groot
  • 4,637
  • 39
  • 52
  • 71