[R] shapes in rgl

From: Duncan Golicher <dgoliche_at_sclc.ecosur.mx>
Date: Wed 24 May 2006 - 04:29:13 EST


Does anyone have a way of producing solid shapes other than spheres in rgl? I am using rgl to produce a simple visualisation of a forest model results using "lollipops". Its just a bit of fun, but as many of the trees are pines I would like to depict their crowns as cones. If there is a solution I need it to work under windows. Here is the example.

library(rgl)
library(misc3d)

Trees3d<-function(x,y,z,rad,cols="lightgreen"){   rgl.bg(color="white")
  rgl.spheres(x,(z-rad),-y,rad,col=cols,alpha=1)

  x<-rep(x,each=3)
  y<-rep(y,each=3)
  z<-rep(z-rad*2,each=3)
  a<-seq(3,length(x),by=3)
  y[a]<-NA

  x[a]<-NA
  z[a]<-NA
  a<-seq(1,length(x),by=3)
  z[a]<-0
  lines3d(x,y,z,col="brown",size=5,add=T)   rgl.bbox(color="black", emission="lightgreen", specular="#3333FF", shininess=5, alpha=0.8 )
}
x<-runif(100,0,100)
y<-runif(100,0,100)
z<-runif(100,10,30)

rad<-z/5

Trees3d(x,y,z,rad)

Thanks,

Duncan Golicher

-- 
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@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed May 24 04:34:08 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 24 May 2006 - 06:10:19 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.