# c
create_trajectory <- function(time, x0, y0, a,b,c){
#
#initialize lengths (Should probably do this in cpp but meh)
x <- vector(mode = "numeric", length = time)
y <- x
# Set starting position
x[1] <- x0
y[1] <- y0
for(i in 2:time) {
x[i] <- y[i-1]-1-sqrt(abs(b*x[i-1]-c))*sign(x[i-1]-1)
y[i] <- a-x[i-1]-1
}
data.frame(x = x, y = y)
}
create_trajectory(99999, 4,20,1,69,42) %>%
mutate(color = if_else(
(sin(x^y)) %% 7==0,
1, 5*x )) %>%
mutate(color = tidyr::replace_na(color, 100))->plot_data
ggplot(plot_data , aes(x, y)) +
geom_point(aes( color=color+100), shape=46, alpha=.05, size = 3) +
geom_point(aes( color=color+75), shape=46, alpha=.05, size = 2) +
geom_point(aes( color=color+50), shape=46, alpha=.05, size = 1.5) +
geom_point(aes(color=color) ,shape=46, alpha=.5, size = 1) +
#geom_path(aes(color=color), size = .5, alpha = .5)+
theme_canvas("black")+
#coord_polar()+
scale_color_viridis_c(option = "magma")
ggsave("worm_hole2.png", type = "cairo")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.