diff --git a/src/Vector2.cpp b/src/Vector2.cpp index d47e44d..abf1b1b 100644 --- a/src/Vector2.cpp +++ b/src/Vector2.cpp @@ -3,10 +3,15 @@ // file, You can obtain one at https ://mozilla.org/MPL/2.0/. #include "Vector2.h" -#include #include "Angle.h" #include "FloatSingle.h" +#if defined(AVR) +#include +#else +#include +#endif + Vector2::Vector2() { x = 0; y = 0; @@ -111,7 +116,11 @@ float Vector2::SignedAngle(Vector2 from, Vector2 to) { if (sqrMagFrom == 0 || sqrMagTo == 0) return 0; if (!isfinite(sqrMagFrom) || !isfinite(sqrMagTo)) +#if defined(AVR) + return NAN; +#else return nanf(""); +#endif float angleFrom = atan2(from.y, from.x); float angleTo = atan2(to.y, to.x); @@ -119,13 +128,18 @@ float Vector2::SignedAngle(Vector2 from, Vector2 to) { } Vector2 Vector2::Rotate(Vector2 v, float angle) { - float sin = (float)sinf(angle * Angle::Deg2Rad); - float cos = (float)cosf(angle * Angle::Deg2Rad); +#if defined(AVR) + float sinValue = sin(angle * Angle::Deg2Rad); + float cosValue = cos(angle * Angle::Deg2Rad); +#else + float sinValue = (float)sinf(angle * Angle::Deg2Rad); + float cosValue = (float)cosf(angle * Angle::Deg2Rad); +#endif float tx = v.x; float ty = v.y; - v.x = (cos * tx) - (sin * ty); - v.y = (sin * tx) + (cos * ty); + v.x = (cosValue * tx) - (sinValue * ty); + v.y = (sinValue * tx) + (cosValue * ty); return v; }