title: GraphicsPath and Region - intersection
body: <p>I write a program that draws strings over/on/under given path. The problem is that I need to check intersections between actually drawing letter and all the previous letters. I do it and it works fine. The only thing is about performance.</p>
  
  <pre><code>private void RemoveOverlapping(Graphics gr, float angle, float x, float y, GraphicsPath graphicsPath)
  {
      Matrix matrix = new Matrix();
      for (;;)
      {
          matrix.Reset();
          matrix.RotateAt(angle, new PointF(x, y));
          graphicsPath.Transform(matrix);
  
          bool isOverlapping = false;
          Region letterRegion = new Region(graphicsPath);
          foreach (Region region in _previousRegions)
          {
              region.Intersect(letterRegion);
  
              if (!region.IsEmpty(gr))
              {
                  matrix.Reset();
                  matrix.RotateAt(360f - angle, new PointF(x, y));
                  graphicsPath.Transform(matrix);
  
                  matrix.Reset();
                  matrix.Translate(1, 0);
                  graphicsPath.Transform(matrix);
  
                  isOverlapping = true;
                  break;
              }
          }
  
          letterRegion.Dispose();
  
          if (!isOverlapping)
              return;
      }
  }
  </code></pre>
  
  <p>I did <code>Alt+F2</code> tests and it told me that <code>region.IsEmpty()</code> takes most of calculation time... Is there any another way (without implementing additional algorithms) to check two <code>Regions/GraphicsPaths</code> intersections?</p>
  
  <p>It's how it looks like:<br />
  <img src="https://i.stack.imgur.com/qZoVl.png" alt="writings"></p>