Shell

## ================================================================================
## Mathematical formula for a shell
## implemented by Karline Soetaert
## ================================================================================
library(plot3Drgl)
par(mar = c(0, 0, 0, 0))
X  <- seq(0, 4*pi, length.out = 200)
Y  <- seq(0, 2*pi, length.out = 100)
M  <- mesh(X, Y)
u  <- M$x
v  <- M$y

# x, y and z grids
x  <- 1.2 ^ u * (1 + cos(v)) * cos(u)
y  <- 1.2 ^ u * (1 + cos(v)) * sin(u)
z  <- 1.2 ^ u * sin(v) - 1.5 * 1.2 ^ u
surf3D(x, y, z, colvar = y, colkey = FALSE, shade = 0.5,
       theta = 150, box = FALSE, plot = FALSE)
plotrgl(lighting = TRUE, smooth = TRUE)

Go back