Skip to content

Instantly share code, notes, and snippets.

@pepijn-devries
Last active August 29, 2015 14:27
Show Gist options
  • Save pepijn-devries/8830c1012f227c06a02a to your computer and use it in GitHub Desktop.
Save pepijn-devries/8830c1012f227c06a02a to your computer and use it in GitHub Desktop.
# Rotate the model with the north pole up
rgl.viewpoint(zoom = .60, theta = 180, phi = 90)
# Tilt the rotational axis with 23.5 degrees
# with a slighlty better view of the Northern hemisphere
U <- par3d("userMatrix")
par3d(userMatrix = rotate3d(U, pi*23.5/180, -0.7,-0.3,0))
# Spin the model and save movie frames
movie3d(spin3d(axis = c(0, 0, 1), rpm = 15), duration = 4,
convert = F, dir = getwd())
# Convert movie frames to animated GIF
shell("convert movie*.png -delay 20 -dither FloydSteinberg -colors 128 globe.gif")
# remove individual animation frames after creating GIF
file.remove(list.files()[grepl("^movie.*png$", list.files())])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment