PolyVtx | R Documentation |
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
PolyVtx(n, r = 1L, xc = 0L, yc = 0L, t1 = 0)
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 |
A data.frame
with n
rows and two columns:
x
X positions of each coordinate
y
Y positions of each coordinate
https://stackoverflow.com/questions/3436453/calculate-coordinates-of-a-regular-polygons-vertices
Angles
(coords <- PolyVtx(5, t1 = 90))
if (requireNamespace("ggplot2", quietly = TRUE)) {
ggplot2::ggplot(coords, ggplot2::aes(x = x, y = y)) + ggplot2::geom_polygon()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.