refactor: better helper name for clarity
This commit is contained in:
parent
397eed8080
commit
e1207b1122
|
|
@ -5,8 +5,8 @@ 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; }
|
||||||
|
|
||||||
void angleToStep(Turret::StepRatio stepRatio, vec2<double> angle,
|
void radToStep(Turret::StepRatio stepRatio, vec2<double> angle,
|
||||||
vec2<long> &step) {
|
vec2<long> &step) {
|
||||||
step.x = angle.x * stepRatio.x;
|
step.x = angle.x * stepRatio.x;
|
||||||
step.y = angle.y * stepRatio.y;
|
step.y = angle.y * stepRatio.y;
|
||||||
}
|
}
|
||||||
|
|
@ -22,5 +22,5 @@ void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset,
|
||||||
|
|
||||||
vec2<double> angle(atan2(dZ, dY) - M_PI / 2, atan2(dZ, dX) - M_PI / 2);
|
vec2<double> angle(atan2(dZ, dY) - M_PI / 2, atan2(dZ, dX) - M_PI / 2);
|
||||||
|
|
||||||
angleToStep(stepRatio, angle, step);
|
radToStep(stepRatio, angle, step);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
maths.h
4
maths.h
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
double degToRad(double deg);
|
double degToRad(double deg);
|
||||||
double radToDeg(double rad);
|
double radToDeg(double rad);
|
||||||
void angleToStep(Turret::StepRatio stepRatio, vec2<double> angle,
|
void radToStep(Turret::StepRatio stepRatio, vec2<double> angle,
|
||||||
vec2<long> &step);
|
vec2<long> &step);
|
||||||
void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset,
|
void cartesianToPolar(Turret::StepRatio stepRatio, Turret::Offset offset,
|
||||||
vec2<long> zero, vec3<double> position, vec2<long> &step);
|
vec2<long> zero, vec3<double> position, vec2<long> &step);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,11 +132,11 @@ Turret &Turret::moveTo(double x, double y, double z, Unit unit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == Unit::RAD) {
|
if (unit == Unit::RAD) {
|
||||||
angleToStep(_step_ratio, vec2<double>(x, y), step);
|
radToStep(_step_ratio, vec2<double>(x, y), step);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit == Unit::DEG) {
|
if (unit == Unit::DEG) {
|
||||||
angleToStep(_step_ratio, vec2<double>(degToRad(x), degToRad(y)), step);
|
radToStep(_step_ratio, vec2<double>(degToRad(x), degToRad(y)), step);
|
||||||
}
|
}
|
||||||
|
|
||||||
long maxDeltaStepX = _step_ratio.x * M_PI_2;
|
long maxDeltaStepX = _step_ratio.x * M_PI_2;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue