Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative diameter circle turtle support #1519

Merged
merged 1 commit into from Apr 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/port/mod/turtle/turtle.cpp
Expand Up @@ -73,7 +73,7 @@ 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 = (angle > 0 ? 1 : -1) * angle * k_headingScale * radius;
mp_float_t length = (angle > 0 ? 1 : -1) * angle * k_headingScale * (radius > 0 ? 1 : -1) * radius;
if (length > 1) {
for (int i = 1; i < length; i++) {
mp_float_t progress = i / length;
Expand All @@ -82,7 +82,7 @@ void Turtle::circle(mp_int_t radius, mp_float_t angle) {
// Keyboard interruption. Return now to let MicroPython process it.
return;
}
setHeadingPrivate(oldHeading+angle*progress);
setHeadingPrivate(oldHeading+angle*progress*((radius>0) ? 1 : -1));
}
forward(1);
setHeading(oldHeading+angle);
Expand Down