I have an image with two points, aligned something like this:
|----------------|
| |
| . |
| |
| . |
First find the centre point:
Point p = new Point((x1-x2)/2, (y1-y2)/2)
Then use trigonomentry to solve for the angle. I'm going to assume we have rebased the origin to our central point so I now have a new x3 and y3 to one of the points.
hypotenuse = SqrRt(x3^2 + y3^2)
We are solving for the unknown angle TH
Sin(TH) = opposite / hypotenuse
So to solve for TH we need:
TH = Asin(y3 / hypotenuse)
Rotate by TH.
See Wikipedia for trigonometric functions reference