Asked by Ian Wood
on 26 Sep 2013

Hi everyone,

I want to find all of the largest empty circles, which pass through any 3 points in a large list of points (~50). I have a code already, with which I have attempted to arrive at a proper solution, but my algorithm does not check for all empty circles accurately. It only checks if there are circles in a sequence of 3 points starting at the highest y-value and continuing all the way down the list of points in this manner.

i.e. first check (1,2,3); second check (2,3,4); third check (3,4,5); etc.

This is not feasible since we could have an empty circle corresponding to points (1,3,6) for example. This is not a sequence of three indices.

What is the proper algorithm to use in this case?

Thanks

Answer by Roger Stafford
on 27 Sep 2013

Accepted answer

I am not sure what you mean by "largest empty circles". Empty of what? However, if the actual question you are asking is how to list all possible combinations of three points chosen from a set of about 50, that is easily done. I assume the numerals you used to identify the points are indices. Just call on matlab's 'nchoosek' function to get all possible combinations of three indices out of a set.

c = nchoosek(1:n,3);

where n is the number of points. The output 'c' will be an array of size n*(n-1)*(n-2)/6 by 3. Each row will have a different combination of three distinct indices ranging from 1 to n.

Ian Wood
on 27 Sep 2013

My apologies, what I mean by "largest empty circles" is that they only include 3 points, and that there are no other points inside of these circles. This function you provided looks useful, although it is not the optimal approach I think this is going to do what I need it to. I will experiment with this method in my code and let you know if it works.

Ian Wood
on 27 Sep 2013

Yep that did it. Thanks a lot for the help Roger!

Answer by Teja Muppirala
on 27 Sep 2013

Edited by Teja Muppirala
on 27 Sep 2013

You don't have to try all combinations. You just need to calculate the Delaunay triangulation. Assuming that no 4 points lie on the same circle (which is a very reasonable assumption, since you could always just slighly perturb them if they do), then every triangle that does not contain any other points in it is part of the Delaunay triangulation, and this Delaunay triangulation is unique.

In other words, given some points in a plane, the Delaunay triangulation consists of all the triangles whose circumcircles do not contain other points, and any triangle whose circumcircle does not contain other points, must be part of the Delaunay triangulation.

n = 50; x = rand(n,1); y = rand(n,1); dt = delaunayTriangulation(x,y) triplot(dt); hold all; plot(x,y,'ko');

Ian Wood
on 27 Sep 2013

Thanks for responding Teja, I understand this is what MATLAB does by default in its voronoi(...) function. I am doing research on another method (plane sweep algorithm) and need to build a code from scratch that doesn't use the same approach as MATLAB. Is this method faster than what Roger suggested?

Teja Muppirala
on 27 Sep 2013

For 50 points, I am pretty sure that one call to delaunayTriangulation and using the result will be much faster than testing out all nchoosek(50,3) = 19600 combinations of 3 points.

Ian Wood
on 27 Sep 2013

That's a good point, thanks for the advice!

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 2 Comments

## Image Analyst (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/88384#comment_171104

I'm not sure I understand. So you have a cluster of points scattered around. And you want to take any and all possible combinations of three of those points and fit a circle to every possible triplet of points as in the FAQ and then check

all other pointsthat you have to see ifanyof them lie inside that circle. If a pointdoes, then skip checking all other points and move on to checkingthe next tripletof points. Does that basically describe what you want to do?## Ian Wood (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/88384#comment_171105

Yes that describes exactly what I want to do. The circle is not valid unless there are no other points lying inside it. It's not the circle calculation i'm looking for, I already have the formula for that. What i'm wondering about is the proper search method (how to determine the points that you can find the largest empty circle with).