quadArea: Area of a quadrilateral

Description Usage Arguments Value Examples

View source: R/quadArea.r

Description

Calculates the area of a quadrilateral by dividing it into two triangles and applying Heron's formula.

Usage

1
quadArea(x, y)

Arguments

x

Numeric list. x coordinates of quadrilateral.

y

Numeric list. y coordinates of quadrilateral.

Value

Numeric (area of a quadrilateral in same units as x and y.

Examples

1
2
3
4
5
6
7
x <- c(0, 6, 4, 1)
y <- c(0, 1, 7, 4)
quadArea(x, y)
plot(1, type='n', xlim=c(0, 7), ylim=c(0, 7), xlab='x', ylab='y')
polygon(x, y)
text(x, y, LETTERS[1:4], pos=4)
lines(x[c(1, 3)], y[c(1, 3)], lty='dashed', col='red')

adamlilith/omnibus documentation built on Nov. 21, 2018, 11:01 a.m.