[pascal]const
{ Degree/Radians }
P2D_RadToDeg = 180.0 / PI;
P2D_DegToRad = PI / 180.0;


type
{ TP2DVector3s }
PP2DVector3s = ^TP2DVector3s;
TP2DVector3s = packed record
x: Single;
y: Single;
z: Single;
end;

procedure TP2DMath.VectorSub(aSrcVector, aDestVector: PP2DVector3s);
begin
aSrcVector.x := aSrcVector.x - aDestVector.x;
aSrcVector.y := aSrcVector.y - aDestVector.y;
aSrcVector.z := aSrcVector.z - aDestVector.z;
end;

function TP2DMath.VectorMag(aSrcVector: PP2DVector3s): Single;
begin
with aSrcVector^ do
begin
Result := Sqrt((X*X) + (Y*Y));
end;
end;


procedure TP2DMath.VectorNorm(aSrcVector: PP2DVector3s);
var
Len, OOL: Single;
begin
Len := VectorMag(aSrcVector);

if Len <> 0 then
begin
OOL := 1.0 / Len;
with aSrcVector^ do
begin
X := X * OOL;
Y := Y * OOL;
end;
end;
end;


function TP2DMath.VectorAngle(aSrcVector, aDestVector: PP2DVector3s): Single;
var
xoy: Single;
R : TP2DVector3s;
begin
R := aSrcVector^;

VectorSub(@R, aDestVector);

VectorNorm(@R);

if R.y = 0 then
begin
R.y := 0.001;
end;

xoy := R.x/R.y;

Result := ArcTan(xoy) * P2D_RadToDeg;
if R.y < 0 then
Result := Result + 180.0;
end;
[/pascal]

This code is from Pyrogine2D which I use in many places in the library. VectorAngle will give you the angle in degrees between two points. I use this in the polygon class (keeps track of rotated line segments) and in the Entity class which provides several rotateToXXX routines (rotate to angle, rotate to position and so on). Note it properly handles the situation that chronozphere pointed out. Hope this helps.