I have a sizable game engine and I'd like a feature for finding the nearest of a list of points.
I could simply use the Pythagorean theorem to find the distances. I know I can't simply add x and y, because that's only theeach distance toand choose the object if you took only right-angled turns. I'm wondering if there's something else I could dominimum one, but that requires iterating through all of them.
I also have a collision system, where essentially I turn objects into smaller objects on a smaller grid, kind (kind of like a minimap,) and only if objects exist in the same gridspace do I check for collisions. I could do that, only make the grid spacing larger to check for closeness. (Rather than checking every single object.) However, that would take additional setup in my base class and clutter up the already cluttered object. Is it worth it?
tl;dr: Is there something efficient and accurate I could use to detect which object is closest, based on a list of points and sizes?