[R] Irregular 3d objects with rgl

Duncan Murdoch murdoch.duncan at gmail.com
Sat Oct 15 14:55:46 CEST 2011


On 14/10/2011 8:14 PM, emorway wrote:
> Hello,
>
> While exploring if rgl is along the lines of what I need, I checked out
> demo("rgl") and didn't find quite what I'm looking for, and am therefore
> seeking additional help/suggestions.
>
> The application is geared towards displaying a 3D rendering of a contaminant
> plume in the subsurface with the following highlights:  Once the plume was
> rendered as a 3D object, a pie-like wedge could be removed (or cut away)
> exposing the higher concentrations within the plume as 'hotter' colors.
> About the closest example I could find is here:
>
> http://mclaneenv.com/graphicdownloads/plume.jpg
>
> Whereas this particular rendering shows a bullet-like object where 3/4 of
> the object is removed, I would like to try and show something where 3/4 of
> the object remains, and where the object has been cut away the colors would
> show concentrations within the plume, just as in the example referenced
> above.  It would seem most software capable of this type of thing is
> proprietary (and perhaps for good reason if it is a difficult problem to
> solve).

That's something you would have to put together yourself, it's not built 
in to rgl.  The misc3d package does something related (3d contour plots 
with cutaways, see ?contour3d).

To do exactly what you're askinf for in rgl, you would render the flat 
concentration image into a .png file, and then use that as a "texture" 
on a polygon.  Getting the details right is the tricky bit.

Duncan Murdoch

> I've put together a very simple 6x6x6 cube with non-zero values internal to
> it representing the plume.  I wondering if an isosurface where "conc" = 0.01
> can be rendered in 3D and then if a "bite" or wedge can be removed from the
> 3d object exposing the higher concentrations inside as discussed above?
>
> x<-c(1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,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0,0,0.1,0.1,0,0,0,0.1,1,1,0.1,0,0,0.1,0.5,1,0.1,0,0,0,0.2,0.2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.05,0.1,0,0,0,0.05,0.8,0.8,0.05,0,0,0.05,0.4,0.8,0.05,0,0,0,0.1,0.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.05,0,0,0,0,0.6,0.6,0.02,0,0,0,0.2,0.5,0.02,0,0,0,0.05,0.05,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.05,0.2,0,0,0,0,0,0.05,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.02,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
>
> plume<-data.frame(cbind(x=x,y=y,z=z,conc=conc))
>
> if it helps to view the concentrations in layer by layer tabular form:
> Layer 1
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.10 0.10 0.00 0.00
> 0.00 0.10 1.00 0.50 0.20 0.00
> 0.00 0.10 1.00 1.00 0.20 0.00
> 0.00 0.00 0.10 0.10 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> Layer 2
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.05 0.05 0.00 0.00
> 0.00 0.05 0.80 0.40 0.10 0.00
> 0.00 0.10 0.80 0.80 0.10 0.00
> 0.00 0.00 0.05 0.05 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> Layer 3
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.60 0.20 0.05 0.00
> 0.00 0.05 0.60 0.50 0.05 0.00
> 0.00 0.00 0.02 0.02 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> Layer 4
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.05 0.00 0.00 0.00
> 0.00 0.00 0.20 0.05 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> Layer 5
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.02 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> Layer 6
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
> 0.00 0.00 0.00 0.00 0.00 0.00
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Irregular-3d-objects-with-rgl-tp3906573p3906573.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list