diff options
author | David Fioramonti | 2018-05-24 19:01:51 -0700 |
---|---|---|
committer | Thierry Crozat | 2018-07-03 23:08:48 +0100 |
commit | 503f0c8f0bc1dc8311e598c6556ee556f32b6c44 (patch) | |
tree | beb69f260361808344c968c7da6691782748f056 /engines/avalanche | |
parent | e00881804f4e3be2f332b6fdd67885f8af124e6d (diff) | |
download | scummvm-rg350-503f0c8f0bc1dc8311e598c6556ee556f32b6c44.tar.gz scummvm-rg350-503f0c8f0bc1dc8311e598c6556ee556f32b6c44.tar.bz2 scummvm-rg350-503f0c8f0bc1dc8311e598c6556ee556f32b6c44.zip |
AVALANCHE: Use degree conversion common math funcs
Noted an atan maybe should be an atan2.
For the atan call I casted the numerator and denominator
separately instead of after they are divided.
Diffstat (limited to 'engines/avalanche')
-rw-r--r-- | engines/avalanche/avalot.cpp | 3 | ||||
-rw-r--r-- | engines/avalanche/graphics.cpp | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index 85cdd9a874..e21999bc42 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -29,6 +29,7 @@ #include "avalanche/avalanche.h" +#include "common/math.h" #include "common/random.h" #include "common/system.h" #include "common/config-manager.h" @@ -1300,7 +1301,7 @@ uint16 AvalancheEngine::bearing(byte whichPed) { int16 deltaX = avvy->_x - curPed->_x; int16 deltaY = avvy->_y - curPed->_y; - uint16 result = (uint16)(atan((float)(deltaY / deltaX)) * 180 / M_PI); + uint16 result = Common::rad2deg<float,uint16>(atan((float)deltaY / (float)deltaX)); // TODO: Would atan2 be preferable? if (avvy->_x < curPed->_x) { return result + 90; } else { diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 6ce6ef2603..002535338e 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -28,6 +28,7 @@ #include "avalanche/avalanche.h" #include "avalanche/graphics.h" +#include "common/math.h" #include "common/system.h" #include "engines/util.h" #include "graphics/palette.h" @@ -199,7 +200,6 @@ void GraphicManager::drawToolbar() { Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color) { Common::Point endPoint; - const float convfac = (float)M_PI / 180.0f; int32 xRadius = radius; int32 yRadius = radius * kScreenWidth / (8 * kScreenHeight); // Just don't ask why... @@ -243,7 +243,7 @@ Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16 uint16 deltaEnd = 91; // Set the end point. - float tempTerm = endAngle * convfac; + float tempTerm = Common::deg2rad<float>(endAngle); endPoint.x = (int16)floor(xRadius * cos(tempTerm) + 0.5) + x; endPoint.y = (int16)floor(yRadius * sin(tempTerm + M_PI) + 0.5) + y; @@ -254,7 +254,7 @@ Common::Point GraphicManager::drawArc(Graphics::Surface &surface, int16 x, int16 int16 xTemp = xNext; int16 yTemp = yNext; // This is used by both sin and cos. - tempTerm = (j + delta) * convfac; + tempTerm = Common::deg2rad<float>(j + delta); xNext = (int16)floor(xRadius * cos(tempTerm) + 0.5); yNext = (int16)floor(yRadius * sin(tempTerm + M_PI) + 0.5); |