mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Final Heading correction
This commit is contained in:
@@ -74,35 +74,6 @@ void Turtle::left(mp_float_t angle) {
|
||||
void Turtle::circle(mp_int_t radius, mp_float_t angle) {
|
||||
mp_float_t oldHeading = heading();
|
||||
mp_float_t length = std::fabs(angle * k_headingScale * radius);
|
||||
/*
|
||||
if (length > 1) {
|
||||
if (angle > 0) {
|
||||
for (int i = 1; i < length; i++) {
|
||||
mp_float_t progress = i / length;
|
||||
// Move the turtle forward
|
||||
if (forward(1)) {
|
||||
// Keyboard interruption. Return now to let MicroPython process it.
|
||||
return;
|
||||
}
|
||||
setHeadingPrivate(oldHeading+std::copysign(angle*progress, radius));
|
||||
}
|
||||
forward(1);
|
||||
setHeading(oldHeading+angle);
|
||||
} else {
|
||||
for (int i = 1; i < length; i++) {
|
||||
mp_float_t progress = i / length;
|
||||
// Move the turtle backward
|
||||
if (forward(-1)) {
|
||||
// Keyboard interruption. Return now to let MicroPython process it.
|
||||
return;
|
||||
}
|
||||
setHeadingPrivate(oldHeading-std::copysign(angle*progress, radius));
|
||||
}
|
||||
forward(-1);
|
||||
setHeading(oldHeading+angle);
|
||||
}
|
||||
}
|
||||
*/
|
||||
int direction = 1; // 1=fwd, -1=backward
|
||||
if (angle < 0) {direction =-1;}
|
||||
if (length > 1) {
|
||||
@@ -116,7 +87,7 @@ void Turtle::circle(mp_int_t radius, mp_float_t angle) {
|
||||
setHeadingPrivate(oldHeading+std::copysign(angle*progress, direction*radius));
|
||||
}
|
||||
forward(direction);
|
||||
setHeading(oldHeading+angle);
|
||||
setHeading(oldHeading+std::copysign(angle, direction*radius));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user