Learn R Programming

SeuratObject (version 5.0.2)

PolyVtx: 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)

Value

A data.frame with n rows and two columns:

x

X positions of each coordinate

y

Y positions of each coordinate

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

References

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

See Also

Angles

Examples

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

Run the code above in your browser using DataLab