I have a 3D scene generated with the R rgl package.
I can save it in PLY format and then export to .u3d (e.g. using Meshlab), but it gives me the following error:
Error in if (sum(normals[1:3, it[j, i]] * normal) < 0) normals[, it[j, :
missing value where TRUE/FALSE needed
Which I really don't know how to solve.
Here is an example file to reproduce the problem. To reproduce simply download the file in the working directory, execute R and run:
library(rgl)
load("alps3d.Rdata") #This loads the alps3d variable
plot3d(alps3d)
writePLY("alps3d.ply")
How can I save the 3d scene in a format which can be itegrated in a .pdf using LaTeX?
You should try writeASY(). It writes for Asymptote, which can produce PRC rather than U3D, but may be good enough. I tried your sample scene, and it takes about 5 minutes to load the result in Acrobat Reader, but it eventually loads and works.
writeASY() is a recent addition to rgl; you'll need to get it from the R-Forge or Github copies.
You can use rgl.postscript
, which allows to export to various formats, including pdf.
Well, the result is not terrific, but that should depend on the type of plot.
> x <- y <- seq(-10, 10, length = 20)
> z <- outer(x, y, function(x, y) x^2 + y^2)
> persp3d(x, y, z, col = 'lightblue')
> rgl.postscript("persp3d.pdf", "pdf")
You can also export to tex
, allowing to do some manual modifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With