feat: Vector::distance
This commit is contained in:
parent
7b61569a2f
commit
94c005f0fd
|
@ -41,6 +41,12 @@ export function mul(l, r) {
|
||||||
return [l[0] * r[0], l[1] * r[1]];
|
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.
|
// Divide two vectors.
|
||||||
//
|
//
|
||||||
// avocado> Vector.div [15, 5], [5, 5]
|
// avocado> Vector.div [15, 5], [5, 5]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user