turn function
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user