programming-examples/js/Math/Calculate degrees between 2 points with inverse Y axis.js
2019-11-15 12:59:38 +01:00

6 lines
201 B
JavaScript

function pointDirection(x1, y1, x2, y2) {
return Math.atan2(y2 - y1, x2 - x1) * 180 / Math.PI;
}
console.log(pointDirection(1, 0, 12, 0));
console.log(pointDirection(1, 0, 1, 10));