feat: Vector::distance

This commit is contained in:
cha0s 2019-07-23 00:18:59 -05:00
parent 7b61569a2f
commit 94c005f0fd

View File

@ -41,6 +41,12 @@ export function mul(l, r) {
return [l[0] * r[0], l[1] * r[1]];
}
export function distance(l, r) {
const xd = l[0] - r[0];
const yd = l[1] - r[1];
return Math.sqrt(xd * xd + yd * yd);
}
// Divide two vectors.
//
// avocado> Vector.div [15, 5], [5, 5]