I have two sets of XY co-ordinate data, and when plotted on a chart together as a joined up scatter chart it appears as a rectangle inside a circle, but never dead centre. I need to now how to find the smallest distance from a point on the rectangle to the nearest point on the circle. To this I have worked out that I need to apply Pythagoras theorem to both sets of data to calculate the vector. This is based on the fact that I subtract the X value for the rectangle from the X value from the circle and likewise for the Y values, this then gives me the two short sides of a right angled triangle the basic formula is this:
SQRT(ABS(Cx-Rx+Cy-Ry)), where C is the circle and R is the rectangle, the ABS is there because negative values would be involved and the ABS function returns all data as positive. This works a treat but here is the problem:
There could be well over a hundred XY co-ordinates for the circle and fifty plus to define the rectangle, for my method to work I would have to perform the calculation many hundreds of times to get the data I need for example:
If my circle has 100 XY co-ordinates and my rectangle 50 XY co-ordinates then I would have to do the calc 5000 times to return all the possible values and then extract the smallest of those.
I have looked using an array but I haven’t a clue how to apply it in this case.
I hope this makes sense.
Any advice or guidence much appreciated.
Tim
Bookmarks