Browse Source

rad->deg; use predefined pi

master
Tim Zeuner 1 year ago
parent
commit
d7fc54cfd0
2 changed files with 4 additions and 4 deletions
  1. 2
    4
      AutonomousMode/Utils/utils.cpp
  2. 2
    0
      AutonomousMode/Utils/utils.h

+ 2
- 4
AutonomousMode/Utils/utils.cpp View File

@@ -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);

+ 2
- 0
AutonomousMode/Utils/utils.h View File

@@ -2,6 +2,8 @@

#include <opencv2/opencv.hpp>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace cv;
using namespace std;

Loading…
Cancel
Save