标签:
/* * 求两点夹角 */ public static float GetAngleTwoPoint(float px1, float py1, float px2, float py2) { float x1 = px2 - px1; float y1 = py2 - py1; float hypotenuse = Mathf.Sqrt(Mathf.Pow(x1, 2) + Mathf.Pow(y1, 2)); float cos = x1 / hypotenuse; float radian = Mathf.Acos(cos); float angle = 180.0f / (Mathf.PI / radian); if (y1 < 0) { angle = -angle; } else if ((y1 == 0) && (x1 < 0)) { angle = 180.0f; } return angle; }
标签:
原文地址:http://www.cnblogs.com/jiangjieqim/p/4748401.html