using System; using Blue; using UnityEngine; public interface IGetAngleByTwoPointUtility:IUtility { double GetAngleByTwoPoint(Vector2 startPoint, Vector2 endPoint); double GetAngleByTwoPoint(float startPoint_X, float startPoint_Y, float endPoint_X, float ednPoint_Y); } public class GetAngleByTwoPointUtility : IGetAngleByTwoPointUtility { /// /// 根据两点求角度 /// /// 开始点坐标 /// 结束点坐标 /// 角度 double IGetAngleByTwoPointUtility.GetAngleByTwoPoint(Vector2 startPoint,Vector2 endPoint) { return GetAngleByTwoPoint(startPoint.x,startPoint.y,endPoint.x,endPoint.y); } /// /// 根据两点求角度 /// /// 开始点X值 /// 开始点Y值 /// 结束点X值 /// 结束点Y值 /// 角度 public double GetAngleByTwoPoint(float startPoint_X,float startPoint_Y ,float endPoint_X,float ednPoint_Y) { return Math.Atan2(ednPoint_Y - startPoint_Y, endPoint_X - startPoint_X) * (180.0 / Math.PI); } }