Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to get midpoint of a link with one segment (Read 1455 times)
solisgsandc
YaBB Newbies
*
Offline



Posts: 40
Joined: Dec 18th, 2009
How to get midpoint of a link with one segment
Jan 8th, 2010 at 4:45pm
Print Post  
I am trying to get a midpoint for any link layout with one segment. Is there an easy way for this. I need to also know the 90 degrees point of a link with a segment count of 1.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to get midpoint of a link with one segment
Reply #1 - Jan 8th, 2010 at 5:50pm
Print Post  
Do you need to insert a point at the middle of the link? It should look like this:

var points = link.ControlPoints;
var p0 = points[0];
var p1 = points[1];
var middle = new Point(
     (p0.X + p1.X) / 2, (p0.Y + p1.Y) / 2);
points.Insert(1, middle);
link.UpdateFromPoints(false, true);
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint