| @@ -156,13 +156,13 @@ namespace GameEngine | |||||
| { | { | ||||
| double tmp = mod - obj.Radius - listObj.Radius; | double tmp = mod - obj.Radius - listObj.Radius; | ||||
| // 计算能走的最长距离,好像这么算有一点误差? | // 计算能走的最长距离,好像这么算有一点误差? | ||||
| tmp = ((int)(tmp*1000 / Math.Cos(Math.Atan2(orgDeltaY, orgDeltaX) - moveVec.Angle()))); | |||||
| tmp = ((int)(tmp * 1000 / Math.Cos(Math.Atan2(orgDeltaY, orgDeltaX) - moveVec.Angle()))); | |||||
| if (tmp < 0 || tmp > uint.MaxValue || double.IsNaN(tmp)) | if (tmp < 0 || tmp > uint.MaxValue || double.IsNaN(tmp)) | ||||
| { | { | ||||
| tmpMax = uint.MaxValue; | tmpMax = uint.MaxValue; | ||||
| } | } | ||||
| else | else | ||||
| tmpMax = tmp/1000.0; | |||||
| tmpMax = tmp / 1000.0; | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| @@ -64,11 +64,11 @@ namespace Preparation.Utility | |||||
| } | } | ||||
| public static double Distance(XY p1, XY p2) | public static double Distance(XY p1, XY p2) | ||||
| { | { | ||||
| long c = (((long)(p1.x - p2.x) * (p1.x - p2.x)) + ((long)(p1.y - p2.y) * (p1.y - p2.y)))*1000000; | |||||
| long t = c/2+1; | |||||
| while (t*t>c||(t+1)*(t+1)<c) | |||||
| t=(c/t+t)/2; | |||||
| return (double)t/1000.0; | |||||
| long c = (((long)(p1.x - p2.x) * (p1.x - p2.x)) + ((long)(p1.y - p2.y) * (p1.y - p2.y))) * 1000000; | |||||
| long t = c / 2 + 1; | |||||
| while (t * t > c || (t + 1) * (t + 1) < c) | |||||
| t = (c / t + t) / 2; | |||||
| return (double)t / 1000.0; | |||||
| } | } | ||||
| public double Length() | public double Length() | ||||
| { | { | ||||