[R] shapes in rgl

Duncan Golicher dgoliche at sclc.ecosur.mx
Tue May 23 23:00:29 CEST 2006


Thanks so much Greg. I was thinking along similar lines but just 
couldn't see how to do it. Great trick, just what I needed. They didn't 
have to be solid, in fact these are potentially more pine like. Now, I 
wonder what other shapes can be made this way.....

Duncan

Greg Snow wrote:

>Try this function (and modify it to your hearts content):
>
>rgl.cones <- function(x,y,z,h=1,r=0.25, n=36, ...){
>
>  r <- rep(r, length.out=length(x))
>  h <- rep(h, length.out=length(x))
>
>  step <- 2*pi/n
>    for (i in seq(along=x)){
>      for (j in seq(0, 2*pi-step, length=n)){
>        tmp.x <- x[i] + c(0, cos(j)*r[i], cos(j+step)*r[i])
>        tmp.z <- z[i] + c(0, sin(j)*r[i], sin(j+step)*r[i])
>        tmp.y <- y[i] + h[i]/2*c(1,-1,-1)
>
>        rgl.triangles(tmp.x,tmp.y,tmp.z,...)
>      }
>    }
>} 
>
>Hope this helps,
>
>  
>


-- 
Dr Duncan Golicher
Ecologia y Sistematica Terrestre
Conservación de la Biodiversidad
El Colegio de la Frontera Sur
San Cristobal de Las Casas, 
Chiapas, Mexico

Email: dgoliche at sclc.ecosur.mx 

Tel: 967 674 9000 ext 1310
Fax: 967 678 2322
Celular: 044 9671041021

United Kingdom Skypein; 020 7870 6251
Skype name: duncangolicher 
Download Skype from http://www.skype.com



More information about the R-help mailing list