Learn R Programming

shotGroups (version 0.7.1)

getBoundingBox: Bounding box for a set of 2D-points

Description

Calculates the vertices of the (axis-parallel) bounding box given a set of 2D-coordinates.

Usage

getBoundingBox(xy)
"getBoundingBox"(xy)
"getBoundingBox"(xy)

Arguments

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 X, Y or Point.X, Point.Y.

Value

A list with the following information about the bounding box:
pts
a numerical 4-vector giving the coordinates xleft, ybottom, xright, ytop.
width
width of the box.
height
height of the box.
FoM
figure of merit, i.e., the average side length of the box: (width + height) / 2.
diag
length of box diagonal.

Details

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.

See Also

drawBox, getMinBBox, getMinCircle

Examples

Run this code
# 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)

Run the code above in your browser using DataLab