Description Usage Arguments Value Author(s) Examples
View source: R/compute-regular-polygons.R
This function computes one or more regular polygons.
1 2 3 4 5 6 7 8 | compute_regular_polygons(
center = c(0, 0),
radius = 1,
rotation = 0,
num.edges = 50,
include.info = TRUE,
...
)
|
center |
Specifies the center(s) of the polygon(s). Can either be a
numeric vector of length 2 (every polygon has the same center), or a
data frame/matrix with 1 row per polygon. If the data frame/matrix has
columns named |
radius |
The radius of the circumscribed circle of the polygon. Can either be a single number or a vector containing one radius per polygon. |
rotation |
The amount of rotation applied to the polygon(s), in radians.
If |
num.edges |
The number of edges that the polygon(s) contain. Can either be a single integer or a vector containing a different number of edges per polygon. |
include.info |
If true, the returned data frame will contain the values for
|
... |
Custom properties that can be used to store additional information about the polygon(s), such as color and opacity. Can either be a single value or a vector containing a different value per polygon. |
A data frame where each row corresponds to the vertex of a polygon. The following columns are included:
x, y |
The coordinates of the vertex |
group |
The group number of the polygon |
radius, rotation, num.edges |
The parameters that are specified in the function call.
Only included if |
... |
Custom columns that are specified in the function call. |
Mathias Isaksen mathiasleanderi@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | set.seed(123)
# This generates 10 polygons with different centers, an individual number of edges
# and a custom property "color"
vertex.df = compute_regular_polygons(
center = data.frame(x = 1:10, y = 1:10),
radius = 0.5,
num.edges = 3:12,
color = sample(c("red", "blue", "green"), 10, replace = TRUE)
)
library(ggplot2)
ggplot()+
geom_polygon(data = vertex.df, aes(x = x, y = y, group = group, fill = color))+
scale_fill_identity()+
coord_fixed()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.