PolyVtx: Polygon Vertices

View source: R/utils.R

PolyVtxR Documentation

Polygon Vertices

Description

Calculate the vertices of a regular polygon given the number of sides and its radius (distance from center to vertex). Also permits transforming the resulting coordinates by moving the origin and altering the initial angle

Usage

PolyVtx(n, r = 1L, xc = 0L, yc = 0L, t1 = 0)

Arguments

n

Number of sides of the polygon

r

Radius of the polygon

xc, yc

X/Y coordinates for the center of the polygon

t1

Angle of the first vertex in degrees

Value

A data.frame with n rows and two columns:

x

X positions of each coordinate

y

Y positions of each coordinate

References

https://stackoverflow.com/questions/3436453/calculate-coordinates-of-a-regular-polygons-vertices

See Also

Angles

Examples

(coords <- PolyVtx(5, t1 = 90))
if (requireNamespace("ggplot2", quietly = TRUE)) {
  ggplot2::ggplot(coords, ggplot2::aes(x = x, y = y)) + ggplot2::geom_polygon()
}


SeuratObject documentation built on May 29, 2024, 12:31 p.m.