shotGroups (version 0.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)

Arguments

xy
a numerical (n x 2)-matrix with the (x,y)-coordinates of n points (1 row of coordinates per point).

Value

  • A list containing the rectangle's vertices, width, and height.
  • ptsa numerical 4-vector giving the coordinates xleft, ybottom, xright, ytop that can be passed to rect.
  • widthwidth of the box.
  • heightheight of the box.

See Also

drawBox, getMinBBox, getMinCircle

Examples

Run this code
xy <- matrix(round(rnorm(20, 100, 15), 1), ncol=2)
bb <- getBoundingBox(xy)
plot(xy, pch=16)
drawBox(bb$pts[1], bb$pts[2], bb$pts[3], bb$pts[4],
        fg='blue', colCtr='blue', pch=4, cex=2)

Run the code above in your browser using DataLab