Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to get arrows intersections (Read 2122 times)
mirko
YaBB Newbies
*
Offline



Posts: 7
Joined: May 17th, 2006
How to get arrows intersections
May 23rd, 2006 at 8:16am
Print Post  
After graph arrangement I need to know if an arrow intersect another one, there's any method to do that ?

Thank's !

Mirko
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get arrows intersections
Reply #1 - May 23rd, 2006 at 10:48am
Print Post  
Unfortunatelly there is no method that can directly check whether two arrows intersect, but here is a simple function that can do this:

Code
Select All
bool Intersect(Arrow a1, Arrow a2)
{
 PointF pt = PointF.Empty;
 PointCollection points1 = a1.ControlPoints;
 PointCollection points2 = a2.ControlPoints;

 for (int i = 0; i < points1.Count - 1; i++)
 {
  for (int j = 0; j < points2.Count - 1; j++)
  {
   PointF k1 = points1[i];
   PointF k2 = points1[i + 1];
   PointF l1 = points2[i];
   PointF l2 = points2[i + 1];

   if (Utilities.segmentIntersect(k1, k2, l1, l2, ref pt))
    return true;
  }
 }

 return false;
} 


Note: Keep in mind that this function would not work properly for bezier arrows.

Stoyo
  
Back to top
 
IP Logged
 
mirko
YaBB Newbies
*
Offline



Posts: 7
Joined: May 17th, 2006
Re: How to get arrows intersections
Reply #2 - May 24th, 2006 at 1:22pm
Print Post  
It works !
Thank's,

Mirko
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint