r2stl {r2stl} | R Documentation |
Save R data to an STL file
Description
r2stl
takes numeric input exactly as with the persp
function. The output is a STL (stereolithography) file.
Usage
r2stl(
x,
y,
z,
filename = "3d-R-object.stl",
object.name = "r2stl-object",
z.expand = FALSE,
min.height = 0.008,
show.persp = FALSE,
strict.stl = FALSE
)
Arguments
x |
A numeric vector with the x-coordinates to plot. |
y |
A numeric vector with the y-coordinates to plot. |
z |
A numeric |
filename |
The STL filename. |
object.name |
The object that is being described must have a name specified inside the file. There's probably no point changing it from the default. |
z.expand |
To force the 3D plot to touch all six faces of the imaginary
cube that surrounds it, set this argument to |
min.height |
The minimum height for the printed material. |
show.persp |
If set to |
strict.stl |
If set to |
Details
To view and test the STL files before printing them can be done with many programs, for example an open-source option is Meshlab https://www.meshlab.net/.
Value
The object returned when close
is used to close the
connection to filename
.
Author(s)
Ian Walker.
Examples
# Let's do the classic persp() demo plot
x <- seq(-10, 10, length = 100)
y <- x
f <- function(x,y) {
r <- sqrt(x^2+y^2)
return(10 * sin(r) / r)
}
z <- outer(x, y, f)
z[is.na(z)] <- 1
file1 <- tempfile(fileext = ".stl")
r2stl(x, y, z, filename = file1, show.persp = TRUE)
# Now let's look at R's Volcano data
z <- volcano
x <- 1:dim(volcano)[1]
y <- 1:dim(volcano)[2]
file2 <- tempfile(fileext = ".stl")
r2stl(x, y, z, filename = file2, show.persp = TRUE)