Changeset 3175 for trunk/sources/HeuristicLab.ExtLibs
- Timestamp:
- 03/22/10 15:48:39 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Diagram elements/Connections/Connection.cs
r3174 r3175 193 193 r1.Inflate(3, 3); 194 194 r2.Inflate(3, 3); 195 //this is like a topological neighborhood196 //the connection is shifted left and right197 //and the point under consideration has to be in between.198 195 if (RectangleF.Union(r1, r2).Contains(p)) 199 196 { 200 //if (p1.Y < p2.Y) //SWNE 201 //{ 202 // o = r1.Left + (((r2.Left - r1.Left) * (p.Y - r1.Bottom)) / (r2.Bottom - r1.Bottom)); 203 // u = r1.Right + (((r2.Right - r1.Right) * (p.Y - r1.Top)) / (r2.Top - r1.Top)); 204 // return ((p.X > o) && (p.X < u)); 205 //} else //NWSE 206 //{ 207 // o = r1.Left + (((r2.Left - r1.Left) * (p.Y - r1.Top)) / (r2.Top - r1.Top)); 208 // u = r1.Right + (((r2.Right - r1.Right) * (p.Y - r1.Bottom)) / (r2.Bottom - r1.Bottom)); 209 // return ((p.X > o) && (p.X < u)); 210 //} 211 return true; 197 PointF connectionVector = new PointF(p2.X - p1.X, p2.Y - p1.Y); 198 PointF normalVector = new PointF(connectionVector.Y, connectionVector.X * -1); 199 PointF pointVector = new PointF(p.X - p1.X, p.Y - p1.Y); 200 201 double normalVectorLength = Math.Sqrt(normalVector.X * normalVector.X + normalVector.Y * normalVector.Y); 202 double distance = Math.Abs(pointVector.X * normalVector.X + pointVector.Y * normalVector.Y) / normalVectorLength; 203 204 return distance < 5; 212 205 } 213 206 return false;
Note: See TracChangeset
for help on using the changeset viewer.