\HeaderA{rectUnique}{Determine a subset of rectangles with unique, non-overlapping areas}{rectUnique}
\keyword{array}{rectUnique}
\keyword{internal}{rectUnique}
\begin{Description}\relax
Given a matrix of rectangular areas, this function determines a subset
of those rectangles that do not overlap. Rectangles are preserved on
a first come, first served basis, with user control over the order in
which the rectangles are processed.
\end{Description}
\begin{Usage}
\begin{verbatim}
rectUnique(m, order = seq(length = nrow(m)), xdiff = 0, ydiff = 0)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{m}] four column matrix defining rectangular areas
\item[\code{order}] order in which matrix columns should be scanned
\item[\code{xdiff}] maximum space between overlapping rectangles in x dimension
\item[\code{ydiff}] maximum space between overlapping rectangles in y dimension
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The \code{m} matrix must contain four colums defining the position of
rectangle sides in the folloing order: left, right, bottom, top. This
function is currently implemented in \code{C} using a an algorithm
with quadratic running time.
\end{Details}
\begin{Value}
A logical vector indicating which rows should be kept.
\end{Value}
\begin{Author}\relax
Colin A. Smith, \email{csmith@scripps.edu}
\end{Author}
\begin{Examples}
\begin{ExampleCode}
m <- rbind(c(0,4,0,3), c(1,3,2,6), c(3,6,4,6))
plot(0, 0, type = "n", xlim=range(m[,1:2]), ylim=range(m[,3:4]))
rect(m[,1], m[,3], m[,2], m[,4])
xcms:::rectUnique(m)
# Changing order of processing
xcms:::rectUnique(m, c(2,1,3))
# Requiring border spacing
xcms:::rectUnique(m, ydiff = 1)
# Allowing adjacent boxes
xcms:::rectUnique(m, c(2,1,3), xdiff = -0.00001)
# Allowing interpenetration
xcms:::rectUnique(m, xdiff = -1.00001, ydiff = -1.00001)
\end{ExampleCode}
\end{Examples}

