diff --git a/maths.cpp b/maths.cpp index 571e6a3..4acb7a5 100644 --- a/maths.cpp +++ b/maths.cpp @@ -20,14 +20,14 @@ void cartesianToPolar(long &stepX, long &stepY, double zeroX, double zeroY, double offsetY = 21.0; // laser to stand double offsetX = 0.0; // unused - x = -x; // natural axis direction + // x = -x; // natural axis direction + y = -y; // natural axis direction double dX = x + offsetX; double dY = y + offsetY; double dZ = z + distance; - double rho = sqrt(pow(dX, 2.0) + pow(dY, 2.0) + pow(dZ, 2.0)); - double angleY = M_PI / 2.0 - acos(dY / rho); - double angleX = atan2(dX, dZ); + double angleY = atan2(dZ, dY) - M_PI / 2; + double angleX = atan2(dZ, dX) - M_PI / 2; angleToStep(stepX, stepY, angleX, angleY); }