File Exchange

## Minimum Enclosing Circle

version 1.1.0.0 (2.54 KB) by
A code to find the minimum circle enclosing a set of given 2d points (Cartesian).

Updated 06 Nov 2015

This code takes an input of a set of given (x,y) points in the Cartesian coordinates and returns the center and radius of the minimum circle enclosing the points. The code is not optimized and may have bugs, but for the many cases I tried it seems to work.
The code is written based on the very nice Java applet found here (link not working anymore): http://heyoka.cs.uiuc.edu/~thite/mincircle/
Credit for the code is to author of the applet.

### Cite As

Yazan Ahed (2020). Minimum Enclosing Circle (https://www.mathworks.com/matlabcentral/fileexchange/6457-minimum-enclosing-circle), MATLAB Central File Exchange. Retrieved .

### Comments and Ratings (5)

Zvika Palkovich

Tried the program for {[0,0] ,[-1,0], [1,0]} and it failed...

Can Aysal

The code is wrong! it does not work... sometimes it gives circles that do not enclose all the pts.

Sergei Koptenko

Probably a good program but it is quite impossible to understand how it should be used from the help part of the function.
1) "n: number of points given". Is this should be n=length(points_coordinates_vector)? If yes, it shouldn't be the input parameter but a code line inside the body of the function (n=length(points); for instance).
2) What is "pts"? is it the coordinates of points? what is the format of this vector?
3) What is the meaning of parameter "m"? If it always should be 1, then again why is it a input parameter not just a line (m=1;) inside the code?
4) From the description of the parameter "bnry" is absolutely unclear what it does and how it should be specified.

A good practice in writing a Matlab functions is to give at least one example how to use the function inside of the help section of the code.

yazan Ahed

Hi Xunkai, thanks!

I'm not really an expert in this stuff, I just needed to include such function in a code that analyzes chemical structure, so I translated the java code mentioned in the description to Matlab.
May be if you check the website of the guy who did the applet and see if you can contact him, maybe he will be interested.

xunkai wei

great
Do you have interest in developing enclosing ball algorithm for object covering ?