The perfect method to compare distance between points is to calculate the euclidean distance between all of them, that is the square root of the sum squared differences between their X and Y components. However, if you just need to know which one is the nearest, you do not need to calculate the exact distance, but you could just compare the squared sums. However, I think you really should calculate at least this to be certain about the results.
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
I'd say this is the most inefficient way to do this, but a way none the less, the goal would be to reduce the scope down to a few points, then use euclidian dist. The trouble with checking 10000 points is without scoping, that would be 10000 x 10000 checks. A KDTree helps solve this.
Ok, in that case you'd better calculate the taxicab distance, which is never lower than the euclidean distance to calculate the bounding box you need, and then compare distances of the points within that box
How’s it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK 🇬🇧
Education
10 plus years* active enterprise development experience and a Fine art degree 🎨
The perfect method to compare distance between points is to calculate the euclidean distance between all of them, that is the square root of the sum squared differences between their X and Y components. However, if you just need to know which one is the nearest, you do not need to calculate the exact distance, but you could just compare the squared sums. However, I think you really should calculate at least this to be certain about the results.
I'd say this is the most inefficient way to do this, but a way none the less, the goal would be to reduce the scope down to a few points, then use euclidian dist. The trouble with checking 10000 points is without scoping, that would be 10000 x 10000 checks. A KDTree helps solve this.
Ok, in that case you'd better calculate the taxicab distance, which is never lower than the euclidean distance to calculate the bounding box you need, and then compare distances of the points within that box
Thank you sir :)