Calculating the angle for a path between two nodes in a graph I want to (programatically) draw an edge between two nodes in a graph, starting on the outside of the nodes. Below is an illustration of what I'm (poorly) trying to describe:

I have the $(x,y)$ coordinates of the two nodes. I'm assuming I need to calculate the angle $a$ between the nodes as illustrated in the following figure (though I'm not sure, it's been a while since I mathed.)

Any help would be greatly appreciated :-)
 A: The equation for the slope of a line is:
       m = (y0 - y1)/(x0 - x1)

The equation of a line in point-slope form is:
       (y - y0) = m*(x - x0)

Solving for y gives:
       y = m*(x - x0) + y0

Now, all you have to do is compute the y that goes best (rounding off) with each x, this gives you many (x,y) coordinate pairs.  Each pair corresponds to a pixel that you can colour by calling some subroutine function designed for that purpose.  That is, at least, one way to do it.  A vertical line would need to be handled specially, since its slope is undefined.
A: (I assume the radius for both circles is $r$, but it's easy to adapt the following if not.)
Similar triangles work well in these situations:
Let the centers of the two circles be $(x_1,y_1)$ and $(x_2,y_2)$.
Then the vector joining the centers is $\langle \Delta x, \Delta y \rangle$, where $\Delta x = x_2-x_1$, and $\Delta y = y_2-y_1$.
Point on circle 1 will be $r$ distance away from its center, so there is some scaling factor $a$ for the vector such that $a \cdot \sqrt{{\Delta x}^2 + {\Delta y}^2} = r$. After you have solved for $a$, then the point on circle 1 along the segment will have coordinates $(x_1 + a \cdot \Delta x, y_1 + a \cdot \Delta y)$.
Similarly, the point on circle 2 will have coordinates $(x_2 - a \cdot \Delta x, y_2 - a \cdot \Delta y)$. (Note that we use the same value of $a$ because the radii are the same, if the radii are different, then just scale accordingly: $a_2 = a_1 * r_2 / r_1$.
A: Okay, if I understand you question correctly, I think this will do the trick. As others have stated, the slope of this line would be $\frac{y_0-y_1}{x_0-x_1}$. Now to find the angle that you are describing, you would have to take this inverse tangent of the slope of the line, that is $\displaystyle{\arctan(\frac{y_0-y_1}{x_0-x_1})}$. If you look at your circle, then look up the definition of the arctangent function, I think you'll see why this works. Let's do a simple example:
If one of the nodes was at the origin, and the other was at $(1,0)$. From the formula, we have $\theta = \arctan(1) = 45^\circ$. As long as you know the $x$ and $y$ coordinates of the nodes, you can employ this formula.
A: So I've got this thing working, using the ideas presented by @recursiverecursion.
This is how I did it (I chose R=15 as the nodes have a radii of 10, which would ensure that the lines started from a point outside the nodes, as per my figure.
$$
  \theta = arctan(\frac{y_0-y_1}{x_0-x_1})\\
\Delta x = R * cos(\theta)\\
\Delta y = R * sin(\theta)\\
$$
Then I drew a line from $(x_o + \Delta x, y_0-\Delta y)$ to $(x_1 - \Delta x, y_1+\Delta y)$. Worked splendidly :-)
