14 lines
342 B
JavaScript
14 lines
342 B
JavaScript
module.exports = squaredDistance
|
|
|
|
/**
|
|
* Calculates the squared euclidian distance between two vec2's
|
|
*
|
|
* @param {vec2} a the first operand
|
|
* @param {vec2} b the second operand
|
|
* @returns {Number} squared distance between a and b
|
|
*/
|
|
function squaredDistance(a, b) {
|
|
var x = b[0] - a[0],
|
|
y = b[1] - a[1]
|
|
return x*x + y*y
|
|
} |