rad->deg; use predefined pi
This commit is contained in:
parent
722898da6d
commit
d7fc54cfd0
@ -1,7 +1,5 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#define PI 3.14159265359
|
|
||||||
|
|
||||||
LFRPoint::LFRPoint(/* args */) : x(0.0), y(0.0)
|
LFRPoint::LFRPoint(/* args */) : x(0.0), y(0.0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -33,7 +31,7 @@ LFRVector::~LFRVector()
|
|||||||
|
|
||||||
double LFRVector::angle(const LFRVector& other) const
|
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
|
double LFRVector::dot(const LFRVector& other) const
|
||||||
@ -71,7 +69,7 @@ int Calcs::calcAngle(int deltaX, int deltaY){
|
|||||||
int refAngle = 0;
|
int refAngle = 0;
|
||||||
|
|
||||||
if(deltaX > 10E-12){
|
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
|
// convert from img coordinates to regbot coordinates
|
||||||
refAngle = -(refAngle);
|
refAngle = -(refAngle);
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <opencv2/opencv.hpp>
|
#include <opencv2/opencv.hpp>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user