Coordinate from bearing and distance


Say you have a current point and a bearing (the direction in which you are actually moving), how do you get the coordinate you would end up with if you moved a certain number of units that way? Or alternatively, if you moved a certain speed where would you be after some time. Kind of the same thing but whatever.

Note that everything here is in radians (2 pi makes a full 360 degrees circle)

var bearing = 0.1 * Math.PI;
var x = 10;
var y = 3;
var distance = 5;

var dx = distance * Math.cos(bearing);
var dy = distance * Math.sin(bearing);

Live example below (mouse your mouse!), or open in jsfiddle.