feat: remove old roll correction
This commit is contained in:
parent
91da5f2793
commit
1831dfe0ab
23
maths.cpp
23
maths.cpp
|
|
@ -1,8 +1,5 @@
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
// rollH atan((22.5 - 18.5) / 236) ~0.97°
|
|
||||||
// rollV ~1°
|
|
||||||
|
|
||||||
double degToRad(double deg) { return deg * M_PI / 180.0; }
|
double degToRad(double deg) { return deg * M_PI / 180.0; }
|
||||||
|
|
||||||
double radToDeg(double rad) { return rad * 180.0 / M_PI; }
|
double radToDeg(double rad) { return rad * 180.0 / M_PI; }
|
||||||
|
|
@ -16,11 +13,6 @@ void angleToStep(long &stepX, long &stepY, double angleX, double angleY) {
|
||||||
stepY = angleY / stepRatioY;
|
stepY = angleY / stepRatioY;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rollCorrection(double x, double max, double width) {
|
|
||||||
double correction = max * (1.0 - cos((10.0 * x) / (width * M_PI))) / 2.0;
|
|
||||||
return x - correction;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cartesianToPolar(long &stepX, long &stepY, double zeroX, double zeroY,
|
void cartesianToPolar(long &stepX, long &stepY, double zeroX, double zeroY,
|
||||||
double x, double y, double z) {
|
double x, double y, double z) {
|
||||||
// TODO remove magic numbers
|
// TODO remove magic numbers
|
||||||
|
|
@ -30,19 +22,12 @@ void cartesianToPolar(long &stepX, long &stepY, double zeroX, double zeroY,
|
||||||
|
|
||||||
x = -x; // natural axis direction
|
x = -x; // natural axis direction
|
||||||
double dX = x + offsetX;
|
double dX = x + offsetX;
|
||||||
double dY = rollCorrection(y + offsetY, 0.2, 400.0);
|
double dY = y + offsetY;
|
||||||
double dZ = z + distance;
|
double dZ = z + distance;
|
||||||
|
|
||||||
double roll = atan2(4.0, 236.0);
|
double rho = sqrt(pow(dX, 2.0) + pow(dY, 2.0) + pow(dZ, 2.0));
|
||||||
double rollY = dX * tan(roll);
|
double angleY = M_PI / 2.0 - acos(dY / rho);
|
||||||
double rollX = dY * tan(roll);
|
double angleX = atan2(dX, dZ);
|
||||||
|
|
||||||
double dXr = dX + rollX;
|
|
||||||
double dYr = dY + rollY;
|
|
||||||
|
|
||||||
double rho = sqrt(pow(dXr, 2.0) + pow(dYr, 2.0) + pow(dZ, 2.0));
|
|
||||||
double angleY = M_PI / 2.0 - acos(dYr / rho);
|
|
||||||
double angleX = atan2(dXr, dZ);
|
|
||||||
|
|
||||||
angleToStep(stepX, stepY, angleX, angleY);
|
angleToStep(stepX, stepY, angleX, angleY);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue