记录下-两点角度计算

public static double GetAngle(double sx, double sy, double ex, double ey)
{
//两点的x、y值
var x = ex - sx;
var y = ey - sy;
//斜边长度
var len = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2));
if (len == 0) return 0; //2点重合
var cos = x / len;
//求出弧度
var radius = Math.Acos(cos);
//求角度
var angle = 180 / (Math.PI / radius);
if (y < 0)
{
angle = 360 - angle;
}
return Math.Round(angle); //取整
}

原文地址:https://www.cnblogs.com/yj2010/p/7299967.html