Fix for #1761: [Feature Request] Add Math.distanceSq(). Also, first attempt at a pull request for Phaser.

This commit is contained in:
Jeremy Osborne 2015-04-28 10:03:35 -07:00
parent 8290e8c371
commit 61f24f1719

View file

@ -1095,6 +1095,26 @@ Phaser.Math = {
},
/**
* Returns the euclidian distance squared between the two given set of
* coordinates (cuts out a square root operation before returning).
*
* @method Phaser.Math#distanceSq
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @return {number} The distance squared between the two sets of coordinates.
*/
distanceSq: function (x1, y1, x2, y2) {
var dx = x1 - x2;
var dy = y1 - y2;
return dx * dx + dy * dy;
},
/**
* Returns the distance between the two given set of coordinates at the power given.
*