[R] export 4D data as povray density files

Jim Lemon jim at bitwrit.com.au
Fri Aug 27 13:01:34 CEST 2010


On 08/27/2010 08:11 PM, baptiste auguie wrote:
> Dear list,
>
> I wish to visualise some 4D data as a kind of colour / translucent
> cloud in 3D. I haven't seen such plots in R (but perhaps I missed a
> feature of rgl). The easiest option I found would be to export the
> data in povray's df3 (density file) format and visualise it with
> povray.
>
> The format specification baffles me a little,
> http://www.povray.org/documentation/view/3.6.1/374/ ; fortunately I
> found a few C++ utilities that could do the conversion from a plain
> ascii datafile to this format. Basically, I wish to create a set of
> xyz coordinates and a scalar function value in R, export it as a
> regular ascii file, convert it to df3 and visualise it in povray.
>
> An example of data from the R side would be,
>
> N<- 10
> xx<- seq(0,N)
> d<- expand.grid(x=xx,y=xx,z=xx)
> d$t<- runif(nrow(d), 0, 255)
>
> cat(file="data.dat", "1 1 1\n")
> write.table(d,file="data.dat",row.names = F,
>              col.names = F,append=T)
>
> I wonder if anyone here ever played with this idea and could offer
> some suggestions (I couldn't get it to work so far).
>
Hi Baptiste,
I once fooled around with a set of functions I wrote to produce 3D plots 
as rendered objects with POVray. The functions really just translated R 
code into POVray code and wrote a file that was then passed to the 
POVray interpreter. If you find that Deepayan's suggestion of misc3d 
won't do it, I could probably dig out the old code I wrote, although it 
wasn't exactly what you are doing.

Jim



More information about the R-help mailing list