mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-27 13:59:01 -05:00
added Vector.angle
This commit is contained in:
parent
7694b7d4f8
commit
5e2a1e5df9
1 changed files with 11 additions and 0 deletions
|
@ -163,4 +163,15 @@ var Vector = {};
|
|||
return { x: -vector.x, y: -vector.y };
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the angle in radians between the two vectors relative to the x-axis
|
||||
* @method angle
|
||||
* @param {vector} vectorA
|
||||
* @param {vector} vectorB
|
||||
* @return {number} The angle in radians
|
||||
*/
|
||||
Vector.angle = function(vectorA, vectorB) {
|
||||
return Math.atan2(vectorB.y - vectorA.y, vectorB.x - vectorA.x);
|
||||
};
|
||||
|
||||
})();
|
Loading…
Reference in a new issue