Created
November 23, 2018 01:49
-
-
Save yutannihilation/69c2ec5476469fea723def0b0cdeedaa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
library(tidyverse) | |
library(magick) | |
steps <- 10000L | |
coil_turns <- 3L | |
max_r <- coil_turns * 2 * pi | |
imgs <- image_graph(300, 300, res = 30) | |
rotation <- pi/4 | |
for (rotation in pi/64 * 1:128) { | |
d <- tibble( | |
radius = 2 * pi * seq(0, steps) / steps * coil_turns, | |
phi = radius - rotation, | |
x = cos(phi) + radius * sin(phi), | |
y = sin(phi) - radius * cos(phi) | |
) | |
p <- ggplot(d) + | |
geom_path(aes(x, y)) + | |
theme_minimal() + | |
coord_equal() + | |
xlim(-max_r, max_r) + | |
ylim(-max_r, max_r) | |
print(p) | |
} | |
dev.off() | |
animation <- image_animate(imgs, fps = 25) | |
image_write(animation, "involute.gif") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment