Determine which objects, stored in a SearchTrees indexing object, fall
within a given rectangle in two-dimensional space.
Usage
rectLookup(tree, ptOne, ptTwo, xlims, ylims)
Arguments
tree
SearchTree. A SearchTree object to perform the lookup on.
ptOne
Numeric. A numeric of length two indicating x and y values for one
corner of the rectangle.
ptTwo
Numeric. A numeric of length two indicating x and y values for the
corner of the rectangle opposite to ptOne
xlims
Numeric. A numeric vector indicating the minimum and maximum x value
for the rectangle. Overrides ptOne and ptTwo
ylims
Numeric. A numeric vector indicating the minimum and maximum y value for
the rectangle. Overrides ptOne and ptTwo
Details
In the case of lookup for rectangular objects, any rectangle which
overlaps the query rectangle will be returned.
Value
A numeric vector indicating the indicies of the object (in the order
they were in when the SearchTree object was created) which fall (at
least partially) within the rectangular query.
Author(s)
Gabriel Becker
See Also
QuadTreeknnLookup
Examples
x = rnorm(100)
y = rnorm(100)
x2 = x + runif(100, .5, 2)
y2 = y + runif(100, .5, 2)
dat2 = cbind(x, y, x2, y2)
tree2 = createTree(dat2, dataType="rect", columns= 1:4)
inrect = rectLookup(tree2, xlim = c(0,1), ylim=c(0, 1))
col = rgb(0, 1, 0, alpha=.5)
plot(x, y2, col="white")
rect(x[inrect], y[inrect], x2[inrect], y2[inrect], col=col)
rect(0, 0, 1, 1, col="blue", lwd=3)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SearchTrees)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SearchTrees/rectLookup.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rectLookup
> ### Title: Perform Rectangular Lookup in 2d Space
> ### Aliases: rectLookup 'rectLookup, QuadTree-method'
> ### Keywords: rectangular lookup query
>
> ### ** Examples
>
> x = rnorm(100)
> y = rnorm(100)
> x2 = x + runif(100, .5, 2)
> y2 = y + runif(100, .5, 2)
> dat2 = cbind(x, y, x2, y2)
> tree2 = createTree(dat2, dataType="rect", columns= 1:4)
> inrect = rectLookup(tree2, xlim = c(0,1), ylim=c(0, 1))
> col = rgb(0, 1, 0, alpha=.5)
> plot(x, y2, col="white")
> rect(x[inrect], y[inrect], x2[inrect], y2[inrect], col=col)
> rect(0, 0, 1, 1, col="blue", lwd=3)
>
>
>
>
>
> dev.off()
null device
1
>