x0 <- y0 <- z0 <- 0
a1 <- 2
a2 <- 3
a3 <- 4
e1 <- 0.5
e2 <- 0.5
v <- seq(from=0,to=1,length=100) * 2*pi
u <- seq(from=-1/2,to=1/2,length=100) * pi
uv <- expand.grid(u,v)
x <- x0 + a1*sign(cos(uv[,2])*cos(uv[,1]))*(abs(cos(uv[,1])))^e1*(abs(cos(uv[,2])))^e2
y <- y0 + a2*sign(sin(uv[,2])*cos(uv[,1]))*(abs(cos(uv[,1])))^e1*(abs(sin(uv[,2])))^e2
z <- z0 + a3*sign(sin(uv[,1]))*(abs(sin(uv[,1])))^e1
library(rgl)
plot3d(x,y,z)
v <- seq(from=0,to=1,length=100)*2*pi
u <- seq(from=-5,to=2,length=100)
uv <- expand.grid(u,v)
p <- 1
q <- 0.5
x <- (sin(uv[,1])+2)*(cos(uv[,2])+0.1*cos(2*uv[,2])) + p*exp(uv[,1])
y <- (sin(uv[,1])+2)*(sin(uv[,2])+0.1*sin(2*uv[,2])) + q*exp(uv[,1])
z <- exp(uv[,1])
plot3d(x,y,z)