Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rectint

Rectangle Intersection Areas


Description

Calculates the area of intersection of rectangles, specified by position vectors x and y.

Usage

rectint(x, y)

Arguments

x, y

both vectors of length 4, or both matrices with 4 columns.

Details

Rectangles are specified as position vectors, that is c(x[1],x[2]) is the lower left corner, x[3] and x[4] are width and height of the rectangle. When x and y are matrices, each row is assumed to be a position vector specifying a rectangle.

Value

Returns a scalar if x and y are vectors. If x is a n-by-4 and y a m-by-4 matrix, then it returns a n-by-m matrix R with entry (i,j) being the area rectint(x[i,], y[j,]).

See Also

Examples

x <- c(0.5, 0.5, 0.25, 1.00)
y <- c(0.3, 0.3, 0.35, 0.75)
rectint(x, y)
# [1] 0.0825

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.