# Re: [R] shapes in rgl

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed 24 May 2006 - 08:52:44 EST

On 5/23/2006 5:00 PM, Duncan Golicher wrote:
> 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.....

Take a look at the qmesh3d man page, and demo(shapes3d) for more ideas. The nice thing about the qmesh stuff is that you can define a shape once, then transform it to display it in different locations, or at different sizes, etc.

Duncan Murdoch

>
> 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,
>>
>>
>>
```

>

>

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 08:57:31 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 - 10: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.