shotGroups (version 0.1)

getMinCircle: Minimum enclosing circle for a set of 2D-points

Description

Calculates center and radius of the minimum enclosing circle given a set of 2D-coordinates.

Usage

getMinCircle(xy)

Arguments

xy
a numerical (n x 2)-matrix with the (x,y)-coordinates of n >= 2 points (1 row of coordinates per point).

Value

  • A list containing the center and radius of the circle.
  • ctra numerical 2-vector giving the (x,y)-coordinates of the circle's center.
  • rada numerical value giving the radius of the circle.

Details

Uses the Skyum algorithm based on the convex hull.

See Also

drawCircle, getMinBBox, getBoundingBox

Examples

Run this code
xy <- matrix(round(rnorm(20, 100, 15), 2), ncol=2)
mc <- getMinCircle(xy)

# determine axis limits so that circle will be visible
xLims <- mc$ctr[1] + c(-mc$rad, mc$rad)
yLims <- mc$ctr[2] + c(-mc$rad, mc$rad)
plot(xy, pch=16, asp=1, xlim=xLims, ylim=yLims)
drawCircle(mc$ctr[1], mc$ctr[2], mc$rad, fg='blue')

Run the code above in your browser using DataLab