Hans-Joachim Klemmt <h-j.klemmt <at> lrz.tu-muenchen.de> writes:
> > Hello, > > I want to draw 3D cylinder objects in R. > > Given is the length and the diameter of the cylinder. > > Has anybody an example? > > Thank you very much! > > Best regards > Here's a starting point, if you want to use the rgl package: cylinder3d <- function(len=1,rad=1,n=30,ctr=c(0,0,0), trans = par3d("userMatrix"),...) { if (missing(trans) && !rgl.cur()) trans <- diag(4) degvec <- seq(0,2*pi,length=n) circ <- cbind(rad*cos(degvec),rad*sin(degvec)) x <- rad*cos(degvec) y <- rad*sin(degvec) p <- c(1,1,rep(2:n,each=4),1,1) z <- rep(c(-1,1,1,-1)*len/2,n) quads3d(x[p],y[p],z,...) } it doesn't draw the ends of the cylinder. good luck, Ben Bolker ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.