meb

Computes the smallest enclosing ball of a point set.

Syntax

[c,r] = meb(A)

[c,r] = meb(A,dim)

[c,r,s] = meb(...)

Inputs

A
The matrix of point coordinates.
Type: double
Dimension: matrix
dim
The dimension of A that contains the points.
dim = 1
stored by column (default).
dim = 2
stored by row.
Type: integer
Dimension: scalar

Outputs

c
The center of the minimum enclosing ball.
Dimension: vector
r
The radius of the minimum enclosing ball.
Dimension: scalar
s
The support set of the minimum enclosing ball.
The orientation of the points is determined by dim.
Dimension: matrix

Example

Find and plot the smallest enslosing circle for a set of random points.

rand('seed', 2013);
x = unifrnd(10,20,10,1);
y = unifrnd(10,20,10,1);
scatter(x, y);
[c,r,s] = meb([x,y], 2)
hold on;
theta = [0:2:360]*(pi/180);
xc = c(1) + r * cos(theta);
yc = c(2) + r * sin(theta);
plot(xc, yc);
xlim([9,21]);
ylim([8,20]);
plot(c(1),c(2));


Figure 1. meb figure 1

Comments

The algorithm works for points with any number of dimensions.