# function for detecting proximity of points

Hi

Is there a function available that will indicate if a set of coordinates is within a proximity of another set of coordinates?

I have a straight line and i want to detect if that is close to another line's coordinates or the edge of a circle.

Steve

edit retag close merge delete

Sort by ยป oldest newest most voted

You actually need to define close, since that has a relative meaning. Do you mean smaller then 5 pixels? Smaller then 50 pixels?

What you basically want to do is look into distance calculation between points. What you could do is determine the center point of both groups of points and then do an euclidean distance between them. You can easily program this yourself.

more

I was looking for a function that could possible accept a distance variable as an input (5 pixels, 10 pixels) when the function is called. Thanks for the advice, when you mention center point are you talking about an (x, y) coordinate? and do an euclidean distance between 2 sets of theses (x, y) coordinated?

( 2013-04-18 02:35:09 -0500 )edit

What I would suggest in your case is

• Create a function bool close(Point point1, Point point2, int distance){ ... }
• Inside the function, calculate the euclidean distance between both
• Once calculated threshold it towards the distance variable and return false or true

This would mean you would need to calculate the center points first. Which can actually be done by taking a point cloud and calculating the average x and average y coordinate.

( 2013-04-18 02:38:41 -0500 )edit