This is a problem I have been trying to figure out - but I guess because I'm not so good with maths - Im always on the back foot - so maybe (hopefully) there is someone out there who could come up with a snazzy algorithm to do the following - as fast as possible really - as speed is the issue here.
I have a coordinate pair (lets call these Base Coordinates") in space, and they look something like the following:
X Y
234, 456
And I have a whole list (array) of other coordinates I want to test against (lets call them Target Coordinates) e.g.
X Y
534, 345
768, 457
32, 256
744, 435
211, 565.......
there may be 2 - 10 or 10,000 coordinate pairs to test against.
GOAL TO ACHIEVE
I want to try and find the CLOSEST pair out of the Target Coordinate list in relation to the Base Coorinate pair - so the code should just return the index of the closest pair at the end of the day - simple eh? Well, I would be interested in testing different algorithms against my own (mine just relied on Pythagoras - finding distance between two pairs, store the distance, then sort to find the shortest distance).
Look forward to seeing any responses.
I have a coordinate pair (lets call these Base Coordinates") in space, and they look something like the following:
X Y
234, 456
And I have a whole list (array) of other coordinates I want to test against (lets call them Target Coordinates) e.g.
X Y
534, 345
768, 457
32, 256
744, 435
211, 565.......
there may be 2 - 10 or 10,000 coordinate pairs to test against.
GOAL TO ACHIEVE
I want to try and find the CLOSEST pair out of the Target Coordinate list in relation to the Base Coorinate pair - so the code should just return the index of the closest pair at the end of the day - simple eh? Well, I would be interested in testing different algorithms against my own (mine just relied on Pythagoras - finding distance between two pairs, store the distance, then sort to find the shortest distance).
Look forward to seeing any responses.