I am developing graph application. In app window there are vertices conneted by edges. User is able to move vertex, and as he do it edge also moves. I am having problem to find pattern to draw arrow representing edge direction depending on both vertex positions.
Here’s an example.
Lets say vertex has width/height = 20px; Edge is drawn from center of Vertex1 to center of Vertex2.
Vertex1.position = new Point(0,0);
Vertex2.position = new Point(100,0);
Edge.point1 = new Point(10,10);
Edge.point2 = new Point(110,10);
//Arrow representing direction from Vertex1 to Vertex2
Arrow.point1 = new Point(100,10);
Arrow.point2 = new Point(90,20);
Arrow.point3 = new Point(90,0);
Question is: Knowing position of edge start/end points, how to calculate arrow points?
Let’s say edge’s starting point has coordinates
(ax, ay), ending point(bx, by), the vertex has radiusw, your arrow has the length of its pointerland the angle between the arrow edgesalphaThen in pseudocode:
The first point of the arrow:
The second point of the arrow:
The third point of the arrow:
Sorry for such poor formatting, I don’t know how to use mathematical markup here. And I hope I didn’t make any errors in the calculations.