This function returns an array [xCoord, yCoord] of new coordinates:
function myFunction(xCoord, yCoord, angle, length) {
length = typeof length !== 'undefined' ? length : 10;
angle = angle * Math.PI / 180;
return [length * Math.cos(angle) + xCoord, length * Math.sin(angle) + yCoord]
}
source
share