From d7fc54cfd0625d8bf40952f4162c4c5617db8148 Mon Sep 17 00:00:00 2001 From: TimZnr Date: Tue, 31 Jan 2023 21:18:53 +0100 Subject: [PATCH] rad->deg; use predefined pi --- AutonomousMode/Utils/utils.cpp | 6 ++---- AutonomousMode/Utils/utils.h | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AutonomousMode/Utils/utils.cpp b/AutonomousMode/Utils/utils.cpp index 6f840c8..7ffbea4 100644 --- a/AutonomousMode/Utils/utils.cpp +++ b/AutonomousMode/Utils/utils.cpp @@ -1,7 +1,5 @@ #include "utils.h" -#define PI 3.14159265359 - LFRPoint::LFRPoint(/* args */) : x(0.0), y(0.0) { } @@ -33,7 +31,7 @@ LFRVector::~LFRVector() double LFRVector::angle(const LFRVector& other) const { - return acos(dot(other)/(this->norm()*other.norm())); + return acos(dot(other)/(this->norm()*other.norm())) * (180.0/M_PI); } double LFRVector::dot(const LFRVector& other) const @@ -71,7 +69,7 @@ int Calcs::calcAngle(int deltaX, int deltaY){ int refAngle = 0; if(deltaX > 10E-12){ - refAngle = (int)((atan(deltaY/deltaX) * 180.0/PI) + 0.5 - (refAngle<0)); //Here 0.5 (or -0.5) is added to round a float number to int right + refAngle = (int)((atan(deltaY/deltaX) * 180.0/M_PI) + 0.5 - (refAngle<0)); //Here 0.5 (or -0.5) is added to round a float number to int right // convert from img coordinates to regbot coordinates refAngle = -(refAngle); diff --git a/AutonomousMode/Utils/utils.h b/AutonomousMode/Utils/utils.h index fde68e8..ec847b0 100644 --- a/AutonomousMode/Utils/utils.h +++ b/AutonomousMode/Utils/utils.h @@ -2,6 +2,8 @@ #include #include +#define _USE_MATH_DEFINES +#include using namespace cv; using namespace std;