0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-26 13:49:01 -05:00

added Vector.angle

This commit is contained in:
liabru 2014-04-24 12:19:52 +01:00
parent 7694b7d4f8
commit 5e2a1e5df9

View file

@ -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);
};
})();