Learn R Programming

PlaneGeometry (version 1.6.0)

LownerJohnEllipse: Löwner-John ellipse (ellipse hull)

Description

Minimum area ellipse containing a set of points.

Usage

LownerJohnEllipse(pts)

Value

An Ellipse object.

Arguments

pts

the points in a two-columns matrix (one point per row); at least three distinct points

Examples

Run this code
pts <- cbind(rnorm(30, sd=2), rnorm(30))
ell <- LownerJohnEllipse(pts)
box <- ell$boundingbox()
plot(NULL, asp = 1, xlim = box$x, ylim = box$y, xlab = NA, ylab = NA)
draw(ell, col = "seaShell")
points(pts, pch = 19)
all(apply(pts, 1, ell$contains)) # should be TRUE

Run the code above in your browser using DataLab