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

Fix small angle freeze #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 13 additions & 7 deletions mobilechelonian/mobilechelonianjs/turtlewidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,20 @@ define(['nbextensions/mobilechelonianjs/paper', "@jupyter-widgets/base"], functi
if (changRot !== 0 && that.turtleShow===1){
var current = new paper.Point(that.oldX, that.oldY);

if(changRot < 0) {
// Turning left
that.changRot += that.rotateSpeed*turtleSpeed;
that.turtle.rotate(-that.rotateSpeed*turtleSpeed,current);
if (Math.abs(changRot) < that.rotateSpeed*turtleSpeed) {
// Change is too small to fix with a rotation step
that.changRot = 0;
that.turtle.rotate(changRot);
} else {
// Turning right
that.changRot -= that.rotateSpeed*turtleSpeed;
that.turtle.rotate(that.rotateSpeed*turtleSpeed,current);
if (changRot < 0) {
// Turning left
that.changRot += that.rotateSpeed*turtleSpeed;
that.turtle.rotate(-that.rotateSpeed*turtleSpeed,current);
} else {
// Turning right
that.changRot -= that.rotateSpeed*turtleSpeed;
that.turtle.rotate(that.rotateSpeed*turtleSpeed,current);
}
}
} else {
//if turtle is off we have to manually set old rotation
Expand Down