Hi,
You can easily fix this by doing the small changes. This one really help

var angle=Math.atan2((y1-y2),(x1-x2))
if (angle<0) {
angle +=3
}
angle=angle*(180/Math.PI)