From d31d7425aa8beb9c0e2f2fed4dd5aba7161320da Mon Sep 17 00:00:00 2001 From: Max Cahill <1bardesign@gmail.com> Date: Wed, 8 May 2024 15:09:59 +1000 Subject: [PATCH] added vec2.nearer (note: can be called as v:nearer(a, b)) --- vec2.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vec2.lua b/vec2.lua index dabbc6a..b3626fa 100644 --- a/vec2.lua +++ b/vec2.lua @@ -413,6 +413,11 @@ function vec2.winding_side(a, b, p) - (p.x - a.x) * (b.y - a.y) end +--return whether a is nearer to v than b +function vec2.nearer(v, a, b) + return v:distance_squared(a) < v:distance_squared(b) +end + ----------------------------------------------------------- -- vector extension methods for special purposes -- (any common vector ops worth naming)