From b22d3a0103ff07d7388d3c38385eb1dcb653c751 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 12 Apr 2019 08:24:31 +1000 Subject: [PATCH] AP_Math: avoid casting floats to int32's for temporary variables Note the use of 64-bit integer arithmetic further down, however --- libraries/AP_Math/polygon.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Math/polygon.cpp b/libraries/AP_Math/polygon.cpp index b55f946383..5468257448 100644 --- a/libraries/AP_Math/polygon.cpp +++ b/libraries/AP_Math/polygon.cpp @@ -43,10 +43,10 @@ bool Polygon_outside(const Vector2 &P, const Vector2 *V, unsigned n) if ((V[i].y > P.y) == (V[j].y > P.y)) { continue; } - const int32_t dx1 = P.x - V[i].x; - const int32_t dx2 = V[j].x - V[i].x; - const int32_t dy1 = P.y - V[i].y; - const int32_t dy2 = V[j].y - V[i].y; + const T dx1 = P.x - V[i].x; + const T dx2 = V[j].x - V[i].x; + const T dy1 = P.y - V[i].y; + const T dy2 = V[j].y - V[i].y; const int8_t dx1s = (dx1 < 0) ? -1 : 1; const int8_t dx2s = (dx2 < 0) ? -1 : 1; const int8_t dy1s = (dy1 < 0) ? -1 : 1;