Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

writeASY

Write Asymptote code for an RGL scene


Description

Asymptote is a language for 3D graphics that is highly integrated with LaTeX. This is an experimental function to write an Asymptote program to approximate an RGL scene.

Usage

writeASY(scene = scene3d(),
         title = "scene", 
         outtype = c("pdf", "eps", "asy", "latex", "pdflatex"), 
         prc = TRUE, 
         runAsy = "asy %filename%", 
         defaultFontsize = 12,
         width = 7, height = 7,
         ppi = 100,
         ids = NULL, 
         version = "2.65")

Arguments

scene

RGL scene object

outtype

What type of file to write? See Details.

prc

Whether to produce an interactive PRC scene.

title

The base of the filename to produce.

runAsy

Code to run the Asymptote program.

defaultFontsize

The default fontsize for text.

width, height

Width and height of the output image, in inches.

ppi

“Pixels per inch” to assume when converting line widths and point sizes (which RGL measures in pixels).

ids

If not NULL, write out just these RGL objects.

version

Asymptote version 2.44 had a definition for its “light()” function that was incompatibly changed in versions 2.47 and 2.50. The current code has been tested with version 2.65. If you are using an older version, set version to your version number and it may work better.

Details

Asymptote is both a language describing a 2D or 3D graphic, and a program to interpret that language and produce output in a variety of formats including EPS, PDF (interactive or static), etc.

The interactive scene produced with prc = TRUE requires outtype = "pdf", and (as of this writing) has a number of limitations:

  • As far as we know, only Adobe Acrobat Reader of a sufficiently recent version can display these scenes.

  • Current versions ignore lighting settings.

Value

The filename of the output file is returned invisibly.

Note

This function is currently under development and limited in the quality of output it produces. Arguments will likely change.

There are a number of differences between the interactive display in Asymptote and the display in RGL. In particular, many objects that are a fixed size in RGL will scale with the image in Asymptote. Defaults have been chosen somewhat arbitrarily; tweaking will likely be needed.

Material properties of surfaces are not yet implemented.

On some systems, the program asy used to process the output has bugs and may fail. Run the example at your own risk!

Author(s)

Duncan Murdoch

References

J. C. Bowman and A. Hammerlindl (2008). Asymptote: A vector graphics language, TUGBOAT: The Communications of the TeX Users Group, 29:2, 288-294.

See Also

scene3d saves a copy of a scene to an R variable; rglwidget, writePLY, writeOBJ and writeSTL write the scene to a file in various other formats.

Examples

## Not run: 
# On some systems, the program  "asy"  used
# to process the output has bugs, so this may fail.
x <- rnorm(20)
y <- rnorm(20)
z <- rnorm(20)
plot3d(x, y, z, type = "s", col = "red")
olddir <- setwd(tempdir())
writeASY(title = "interactive")  # Produces interactive.pdf
writeASY(title = "noninteractive", prc = FALSE) # Produces noninteractive.pdf
setwd(olddir)

## End(Not run)

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.