View source: R/getMinEllipse.R
getMinEllipse | R Documentation |
Calculates center, shape matrix, and area of the minimum enclosing ellipse given a set of 2D-coordinates using Khachiyan's algorithm.
getMinEllipse(xy, tol = 0.001, max_iter = 1000) ## S3 method for class 'data.frame' getMinEllipse(xy, tol = 0.001, max_iter = 1000) ## Default S3 method: getMinEllipse(xy, tol = 0.001, max_iter = 1000)
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 |
tol |
numerical tolerance value. Should be < 1. |
max_iter |
maximum number of iterations. |
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.
A list containing the center, (2 x 2)-shape matrix, and area of the ellipse.
ctr |
a numerical 2-vector giving the (x,y)-coordinates of the ellipse's center. |
E |
a numerical positive definite (2 x 2)-matrix defining the ellipse in the form ((x-c)' E (x-c)) <= 1 |
cov |
matrix, whose eigen-structure determines shape of ellipse. Inverse of E. Useful for plotting with |
area |
a numerical value giving the area of the ellipse. |
shape |
a numerical vector with the orientation of the ellipse's major axis pointing up as returned by |
size |
a numerical vector with the lengths of the semi-axes of the ellipse. |
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
Todd MJ and Yildrim EA. On Khachiyan's Algorithm for the Computation of Minimum Volume Enclosing Ellipsoids. Discrete Applied Mathematics 2007: 155: 1731-1744. https://people.orie.cornell.edu/miketodd/TYKhach.pdf
Jacob. Bounding ellipse. https://stackoverflow.com/a/1768440.
drawEllipse
,
getMinCircle
,
getMinBBox
,
getBoundingBox
# coordinates given by a suitable data frame me <- getMinEllipse(DFsavage, tol=0.001) plot(point.y ~ point.x, data=DFsavage, pch=16, asp=1) drawEllipse(me, fg='blue') # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 2), ncol=2) getMinEllipse(xy, tol=0.001) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.