Skip to content

Instantly share code, notes, and snippets.

@fabulousduck
Created November 27, 2018 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabulousduck/0021526b475d06d77dfd675146674b32 to your computer and use it in GitHub Desktop.
Save fabulousduck/0021526b475d06d77dfd675146674b32 to your computer and use it in GitHub Desktop.
private void updateVehicle(double dt) {
this.position.x += Math.cos ( Math.PI * this.orientation / 180.0) * dt *
(this.leftWheel.getSpeed () + this.rightWheel.getSpeed ()) / 2;
this.position.y += Math.sin ( Math.PI * this.orientation / 180.0) * dt *
(this.leftWheel.getSpeed () + this.rightWheel.getSpeed ()) / 2;
this.position.orientation += 0.5 * dt * ( this.rightWheel.getSpeed() - this.leftWheel.getSpeed());
this.position.orientation = ( this.position.orientation + 360) % 360; // keep orientation within range 0 -360
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment