Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getAngleRadians(x0, y0, x1, y1) {
- // radians = atan2(deltaY, deltaX)
- const y = y1 - y0;
- const x = x1 - x0;
- return Math.atan2(y, x);
- }
- function getAngleDeg(x0, y0, x1, y1) {
- // degrees = atan2(deltaY, deltaX) * (180 / PI)
- const y = y1 - y0;
- const x = x1 - x0;
- return Math.atan2(y, x) * (180 / Math.PI);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement