hedgewars/uUtils.pas
changeset 7565 00568d3054d0
parent 7386 e82a076df09b
parent 7548 c7a21fc530de
child 7896 67217e6108fd
--- a/hedgewars/uUtils.pas	Sun Aug 12 23:05:15 2012 +0400
+++ b/hedgewars/uUtils.pas	Sun Aug 19 22:13:41 2012 +0400
@@ -43,7 +43,7 @@
 function  StrToInt(s: shortstring): LongInt;
 function  FloatToStr(n: hwFloat): shortstring;
 
-function  DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
+function  DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; inline;
 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
 function  DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
 function  DxDy2AttackAnglef(const _dY, _dX: extended): LongInt;
@@ -186,15 +186,11 @@
 end;
 
 
-function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
+function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; inline;
 var dY, dX: Extended;
 begin
-dY:= _dY.QWordValue / $100000000;
-if _dY.isNegative then
-    dY:= - dY;
-dX:= _dX.QWordValue / $100000000;
-if _dX.isNegative then
-    dX:= - dX;
+dY:= hwFloat2Float(_dY);
+dX:= hwFloat2Float(_dX);
 DxDy2Angle:= arctan2(dY, dX) * 180 / pi
 end;
 
@@ -202,12 +198,8 @@
 const _16divPI: Extended = 16/pi;
 var dY, dX: Extended;
 begin
-dY:= _dY.QWordValue / $100000000;
-if _dY.isNegative then
-    dY:= - dY;
-dX:= _dX.QWordValue / $100000000;
-if _dX.isNegative then
-    dX:= - dX;
+dY:= hwFloat2Float(_dY);
+dX:= hwFloat2Float(_dX);
 DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f
 end;
 
@@ -215,12 +207,8 @@
 const MaxAngleDivPI: Extended = cMaxAngle/pi;
 var dY, dX: Extended;
 begin
-dY:= _dY.QWordValue / $100000000;
-if _dY.isNegative then
-    dY:= - dY;
-dX:= _dX.QWordValue / $100000000;
-if _dX.isNegative then
-    dX:= - dX;
+dY:= hwFloat2Float(_dY);
+dX:= hwFloat2Float(_dX);
 DxDy2AttackAngle:= trunc(arctan2(dY, dX) * MaxAngleDivPI)
 end;