View source: R/getBoundingBox.R
getBoundingBox | R Documentation |
Calculates the vertices of the (axis-parallel) bounding box given a set of 2D-coordinates.
getBoundingBox(xy) ## S3 method for class 'data.frame' getBoundingBox(xy) ## Default S3 method: getBoundingBox(xy)
xy |
either a numerical (n x 2)-matrix with the (x,y)-coordinates of n 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.
A list with the following information about the bounding box:
pts |
a numerical 4-vector giving the coordinates |
width |
width of the box. |
height |
height of the box. |
FoM |
figure of merit, i.e., the average side length of the box: ( |
diag |
length of box diagonal. |
drawBox
,
getMinBBox
,
getMinCircle
# coordinates given by a suitable data frame bb <- getBoundingBox(DFsavage) # draw points and bounding box plot(point.y ~ point.x, data=DFsavage, asp=1, pch=16) drawBox(bb, fg='blue', colCtr='blue', pch=4, cex=2) bb$FoM # figure of merit # coordinates given by a matrix ## Not run: xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2) getBoundingBox(xy) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.