# getCentroid: Calculate the centroid of a polygon. In venn: Draw Venn Diagrams

## Description

This function takes a list of dataframes or a matrices containing x and y values, which define zones (polygons), and calculates their centroids.

## Usage

 `1` ```getCentroid(data) ```

## Arguments

 `data` A matrix or a dataframe with two columns, for x and y coordinates

## Details

Most of the coordinates for the intersection labels in this package were calculated using the formula for a centroid of a non-self-intersecting closed polygon, approximated by 10 vertices.

## Value

A list with x and y coordinates, for each zone in the input list.

## References

Centroid. (n.d.). In Wikipedia. Retrieved January 06, 2016, from https://en.wikipedia.org/wiki/Centroid

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```venn("0110") # centroid for the intersection "0110" in a 4 set diagram centroid <- getCentroid(getZones("0110"))[] text(centroid, centroid, labels = "0110", cex = 0.85) # centroids for the two zones in the "E not A" zones venn(5) area <- getZones("0---1") # list of length 2 polygon(area[], col="lightblue") polygon(area[], col="lightblue") text(do.call("rbind", getCentroid(area)), labels = c("zone 1", "zone 2"), cex = 0.85) ```

venn documentation built on March 16, 2021, 1:08 a.m.