hedgewars/uUtils.pas
changeset 7547 6e9c5feb88eb
parent 7191 9419294e5f33
child 7548 c7a21fc530de
equal deleted inserted replaced
7546:b50556f2a0e8 7547:6e9c5feb88eb
   183 
   183 
   184 
   184 
   185 function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
   185 function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
   186 var dY, dX: Extended;
   186 var dY, dX: Extended;
   187 begin
   187 begin
   188 dY:= _dY.QWordValue / $100000000;
   188 dY:= hwFloat2Float(_dY);
   189 if _dY.isNegative then
   189 dX:= hwFloat2Float(_dX);
   190     dY:= - dY;
       
   191 dX:= _dX.QWordValue / $100000000;
       
   192 if _dX.isNegative then
       
   193     dX:= - dX;
       
   194 DxDy2Angle:= arctan2(dY, dX) * 180 / pi
   190 DxDy2Angle:= arctan2(dY, dX) * 180 / pi
   195 end;
   191 end;
   196 
   192 
   197 function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
   193 function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
   198 const _16divPI: Extended = 16/pi;
   194 const _16divPI: Extended = 16/pi;
   199 var dY, dX: Extended;
   195 var dY, dX: Extended;
   200 begin
   196 begin
   201 dY:= _dY.QWordValue / $100000000;
   197 dY:= hwFloat2Float(_dY);
   202 if _dY.isNegative then
   198 dX:= hwFloat2Float(_dX);
   203     dY:= - dY;
       
   204 dX:= _dX.QWordValue / $100000000;
       
   205 if _dX.isNegative then
       
   206     dX:= - dX;
       
   207 DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f
   199 DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f
   208 end;
   200 end;
   209 
   201 
   210 function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
   202 function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
   211 const MaxAngleDivPI: Extended = cMaxAngle/pi;
   203 const MaxAngleDivPI: Extended = cMaxAngle/pi;
   212 var dY, dX: Extended;
   204 var dY, dX: Extended;
   213 begin
   205 begin
   214 dY:= _dY.QWordValue / $100000000;
   206 dY:= hwFloat2Float(_dY);
   215 if _dY.isNegative then
   207 dX:= hwFloat2Float(_dX);
   216     dY:= - dY;
       
   217 dX:= _dX.QWordValue / $100000000;
       
   218 if _dX.isNegative then
       
   219     dX:= - dX;
       
   220 DxDy2AttackAngle:= trunc(arctan2(dY, dX) * MaxAngleDivPI)
   208 DxDy2AttackAngle:= trunc(arctan2(dY, dX) * MaxAngleDivPI)
   221 end;
   209 end;
   222 
   210 
   223 function DxDy2AttackAnglef(const _dY, _dX: extended): LongInt; inline;
   211 function DxDy2AttackAnglef(const _dY, _dX: extended): LongInt; inline;
   224 begin
   212 begin