getMinCircle | R Documentation |
Calculates center and radius of the minimum enclosing circle given a set of 2D-coordinates.
getMinCircle(xy)
## S3 method for class 'data.frame'
getMinCircle(xy)
## Default S3 method:
getMinCircle(xy)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n >= 2 points (1 row of coordinates per point), or a data frame with either the variables |
No coordinate transforms are done (unlike in groupLocation
, groupShape
, groupSpread
), i.e., origin is not assumed to be in top-left corner, and points are not taken relative to point of aim.
Uses the Skyum algorithm based on the convex hull.
A list containing the center and radius of the circle.
ctr |
a numerical 2-vector giving the (x,y)-coordinates of the circle's center. |
rad |
a numerical value giving the radius of the circle. |
Computational Geometry Algorithms Library. 2021. CGAL Chapter 65: Bounding Volumes. https://doc.cgal.org/Manual/latest/doc_html/cgal_manual/Bounding_volumes/Chapter_main.html Fischer, K.; Gaertner, B.; Kutz, M. 2003. Fast smallest-enclosing-ball computation in high dimensions. In: Proceedings of the 11th European Symposium on Algorithms (ESA), 630-641. https://github.com/hbf/miniball Gaertner, B. 2021. Miniball: Smallest Enclosing Balls of Points. https://people.inf.ethz.ch/gaertner/subdir/software/miniball.html Skyum, S. 1991. A simple algorithm for computing the smallest enclosing circle. Information Processing Letters 37(3), 121-125. Welzl, E. 1991. Smallest enclosing disks (balls and ellipsoids). In: Maurer H. (eds), New Results and New Trends in Computer Science 555, 359-370. doi 10.1007/BFb0038202.
drawCircle
,
getMinBBox
,
getBoundingBox
# coordinates given by a suitable data frame
mc <- getMinCircle(DFsavage)
# 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(point.y ~ point.x, data=DFsavage,
pch=16, asp=1, xlim=xLims, ylim=yLims)
drawCircle(mc, fg='blue')
# coordinates given by a matrix
## Not run:
xy <- matrix(round(rnorm(20, 100, 15), 2), ncol=2)
getMinCircle(xy)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.