Description Usage Arguments Value Examples

View source: R/repgrid-plots.r

Detect if two rectangles overlap. The overlap is assessed in x AND y.

1 | ```
doRectanglesOverlap(a, b, margin=0)
``` |

`a` |
vector with four coordinates |

`b` |
vector with four coordinates |

`logical`

. TRUE if rectangles overlap.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ```
## Not run:
#overlap in x and y
a <- c(0,0,2,2)
b <- c(1,1,4,3)
plot(c(a,b), c(a,b), type="n")
rect(a[1], a[2], a[3], a[4])
rect(b[1], b[2], b[3], b[4])
doRectanglesOverlap(a,b)
# b contained in a vertically
a <- c(5,0,20,20)
b <- c(0, 5,15,15)
plot(c(a,b), c(a,b), type="n")
rect(a[1], a[2], a[3], a[4])
rect(b[1], b[2], b[3], b[4])
doRectanglesOverlap(a,b)
# overlap only in y
a <- c(0,0,2,2)
b <- c(2.1,1,4,3)
plot(c(a,b), c(a,b), type="n")
rect(a[1], a[2], a[3], a[4])
rect(b[1], b[2], b[3], b[4])
doRectanglesOverlap(a,b)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.