mirror of
https://github.com/photonstorm/phaser
synced 2024-11-30 00:21:04 +00:00
13 lines
342 B
JavaScript
13 lines
342 B
JavaScript
import Clamp from 'math/Clamp.js';
|
|
|
|
// Get the angle in radians between the two given vectors
|
|
|
|
export default function (a, b) {
|
|
|
|
const dot = a[0] * b[0] + a[1] * b[1];
|
|
const len = Math.sqrt(a[0] * a[0] + a[1] * a[1]);
|
|
const lenV = Math.sqrt(b[0] * b[0] + b[1] * b[1]);
|
|
|
|
return Math.acos(Clamp(dot / (len * lenV), -1, 1));
|
|
|
|
}
|