Skip to content

Commit

Permalink
One use of fabs() on a variable is sufficient.
Browse files Browse the repository at this point in the history
Use DEG2RAD another place where it makes sense to do so.
  • Loading branch information
JMakey committed Jul 3, 2015
1 parent 88d8d4a commit 436f9e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bzflag/RobotPlayer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void RobotPlayer::projectPosition(const Player *targ,const float t,float &x,floa
double omega=fabs(targ->getAngularVelocity());
double sx,sy;

if ((targ->getStatus() & PlayerState::Falling) || fabs(omega) < 2*M_PI / 360 * 0.5)
if ((targ->getStatus() & PlayerState::Falling) || omega < DEG2RAD * 0.5)
{
sx=t*hisvx;
sy=t*hisvy;
Expand All @@ -61,7 +61,7 @@ void RobotPlayer::projectPosition(const Player *targ,const float t,float &x,floa
{
double hisspeed = hypotf(hisvx, hisvy);
double alfa = omega * t;
double r = hisspeed / fabs(omega);
double r = hisspeed / omega;
double dx = r * sin(alfa);
double dy2 = r * (1 - cos(alfa));
double beta = atan2(dy2, dx) * (targ->getAngularVelocity() > 0 ? 1 : -1);
Expand Down

0 comments on commit 436f9e5

Please sign in to comment.