turn function

This commit is contained in:
Leen Dereu
2018-02-27 12:39:04 +01:00
parent 4d1c5ad2e3
commit 05a795b493

View File

@@ -191,6 +191,9 @@ public class Worm {
* |0 <= new.orientation < 2pi
*/
public void turn(double angleToAdd) {
assert 0 <= angleToAdd && angleToAdd < 2 * Math.PI;
assert 0 <= angleToAdd && angleToAdd < (2 * Math.PI);
if (0 <= (this.orientation + angleToAdd) && (this.orientation + angleToAdd) < (2 * Math.PI))
setOrientation(this.orientation + angleToAdd);
setOrientation((this.orientation + angleToAdd)%(2 * Math.PI));
}
}