2022-11-10 16:45:34 +01:00
|
|
|
#include "utils.h"
|
|
|
|
|
2022-12-14 12:30:54 +01:00
|
|
|
#define PI 3.14159265359
|
|
|
|
|
2022-11-10 16:45:34 +01:00
|
|
|
LFRPoint::LFRPoint(/* args */) : x(0.0), y(0.0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRPoint::LFRPoint(double x, double y): x(x), y(y)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRPoint::~LFRPoint()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRVector::LFRVector(/* args */) : LFRPoint()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRVector::LFRVector(double x, double y) : LFRPoint(x, y)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRVector::LFRVector(const LFRPoint& pt) : LFRPoint(pt)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRVector::~LFRVector()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRLine::LFRLine(/* args */) : start(), dir()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRLine::LFRLine(LFRPoint start, LFRVector dir) : start(start), dir(dir)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRLine::LFRLine(LFRPoint start, LFRPoint end) : start(start)
|
|
|
|
{
|
|
|
|
dir = end - start;
|
|
|
|
}
|
|
|
|
|
|
|
|
LFRLine::~LFRLine()
|
|
|
|
{
|
|
|
|
}
|
2022-11-14 17:31:01 +01:00
|
|
|
|
2022-11-15 17:33:20 +01:00
|
|
|
|
|
|
|
|
2022-12-14 16:14:00 +01:00
|
|
|
int Calcs::calcAngle(int deltaX, int deltaY){
|
2022-12-14 12:30:54 +01:00
|
|
|
|
|
|
|
int refAngle = 0;
|
|
|
|
|
|
|
|
if(deltaX > 10E-12){
|
2022-12-14 16:14:00 +01:00
|
|
|
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
|
2022-12-14 12:30:54 +01:00
|
|
|
|
|
|
|
// convert from img coordinates to regbot coordinates
|
|
|
|
refAngle = -(refAngle);
|
|
|
|
|
|
|
|
if (refAngle > 90)
|
2022-12-14 16:14:00 +01:00
|
|
|
refAngle = refAngle - 180;
|
2022-12-14 12:30:54 +01:00
|
|
|
}else{
|
|
|
|
refAngle = -90;
|
|
|
|
}
|
|
|
|
return refAngle;
|
|
|
|
|
2022-11-14 17:31:01 +01:00
|
|
|
}
|