Description Usage Arguments Value Note Author(s) Examples
View source: R/rounded-regular-polygon.R
This function computes the vertices of a regular polygon with rounded corners.
1 2 3 4 5 6 7 8 | rounded_regular_polygon(
num.edges = 3,
center = c(0, 0),
radius = 1,
rotation = 0,
corner.radius = 0.25,
vertices.per.corner = 50
)
|
num.edges |
The number of edges that the regular polygon contains. |
center |
The center/centroid of the shape. Can either be a 1 x 2 data frame/matrix or a numeric vector length 2. |
radius |
The radius of the circumscribed circle of the regular polygon. |
rotation |
The amount of rotation applied to the shape, in radians. |
corner.radius |
The radius of the circular arcs. |
vertices.per.corner |
The number of vertices that each circular arc consists of. |
A data frame containing the columns x
and y
, where each
row is a vertex in the rounded polygon.
The result may contain less than num.edges*vertices.per.corner
vertices.
In certain situations, consecutive vertices will end up having the same coordinates.
The duplicates are then removed.
Mathias Isaksen mathiasleanderi@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Create a rounded hexagon
vertex.df = rounded_regular_polygon(
num.edges = 6,
center = c(5, 6),
radius = 2,
rotation = pi/4,
corner.radius = 0.5
)
# How the rounded hexagon looks:
library(ggplot2)
ggplot()+
geom_polygon(data = vertex.df, aes(x = x, y = y))+
coord_fixed()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.