# Load packages
pacman::p_load(pacman,tidyverse,GGally,ggthemes,ggplot2,ggvis,httr,plotly,rio,rmarkdown,shiny,rgl)
# Golden ratio
phi <- (1 + sqrt(5)) / 2
# Define the helix equations
t <- seq(0, 10 * pi, length.out = 1000)
r <- 1
c <- 0.1 * phi # Incorporating golden ratio into the z-increment
x1 <- r * cos(t)
y1 <- r * sin(t)
z1 <- c * t
x2 <- r * cos(t + pi)
y2 <- r * sin(t + pi)
z2 <- c * t
# Plot using rgl
plot3d(x1, y1, z1, type = "l", col = "red", xlab = "X", ylab = "Y", zlab = "Z", aspect = c(1, 1, 1))
lines3d(x2, y2, z2, col = "blue")
# Add cross-links to simulate DNA rungs (by removing this and the following 5 lines of code)
n_rungs <- 100 # Number of rungs (you are left just with the double helix plot)
interval <- length(t) / n_rungs
for (i in seq(1, length(t), by = interval)) {
lines3d(c(x1[i], x2[i]), c(y1[i], y2[i]), c(z1[i], z2[i]), col = "lightgreen")
}
# Show the plot
rglwidget()