Skip to content

Instantly share code, notes, and snippets.

@brownag
Created March 30, 2023 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brownag/86a9da66d87e2f6ce603d91acdd73a26 to your computer and use it in GitHub Desktop.
Save brownag/86a9da66d87e2f6ce603d91acdd73a26 to your computer and use it in GitHub Desktop.
torme, toryou, torus
# torus
ratio <- sort(c((seq(1, 10, 0.101)) / 10))#$, (seq(1, 10, 2))))
plt <- function(i){
d <- expand.grid(data.frame(
R = 1,
r = 1 * i,
theta = seq(0, 2 * pi, 0.25),
phi = seq(0, 2 * pi, 0.25)
)) |> within({
x <- (R + r * cos(theta)) * cos(phi)
y <- (R + r * cos(theta)) * sin(phi)
z <- r * sin(theta)
})
rgl::plot3d(d$x, d$y, d$z, box=FALSE, axes=FALSE)
rgl::snapshot3d(sprintf("foo/foo%s.png", i))
}
sapply(ratio, plt)
rgl::plot3d(d$x, d$y, d$z, box=FALSE, axes=FALSE, xlab="", ylab="", zlab="")
rgl::snapshot3d(sprintf("foo/foo%s.png", i))
M <- par3d("userMatrix")
movie3d(par3dinterp(time = (0:4)*0.75, userMatrix = list(M,
rotate3d(M, pi, 1, 0, 0),
rotate3d(M, pi, 0, 1, 0),
rotate3d(M, pi, 1, 0, 1),
rotate3d(M, pi, 1, 1, 0) ) ),
duration = 5, movie = "foo", dir = "foo")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment