Created
March 28, 2019 11:57
-
-
Save MartinMSPedersen/6e5a9aa182d49d196ab5bc7c1d4e26c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
polygon <- function(n) { | |
tibble( | |
x = accumulate(1:(n-1), ~.x+cos(.y*2*pi/n), .init = 0), | |
y = accumulate(1:(n-1), ~.x+sin(.y*2*pi/n), .init = 0), | |
xend = accumulate(2:n, ~.x+cos(.y*2*pi/n), .init = cos(2*pi/n)), | |
yend = accumulate(2:n, ~.x+sin(.y*2*pi/n), .init = sin(2*pi/n))) | |
} | |
ggplot(polygon(5) + geom_segment(aes(x=x, y=y, xend=xend, yend=yend)) + theme_void() + coord_equal() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment