I am getting as an input 4 points.
p1=(x1, y1), p2=(x2, y2), p3=(x3, y3), p4=(x4, y4).
Now I have calculated the distances between p1p2, p2p3, p3p4 and p4p1.
To get the angle between two vectors, you simply use their inner product:
v1 = p1-p2; v2 = p3-p2;
Normalize to unit vectors and take inner product:
n1 = v1/norm(v1); n2 = v2/norm(v2); cos_p2 = dot(n1,n2);
And the resulting angle is
acos(cos_p2)