Title: | Visualizing Data using a 3D Printer |
---|---|
Description: | Converts data to STL (stereolithography) files that can be used to feed a 3-dimensional printer. The 3-dimensional output from a function can be materialized into a solid surface in a plastic material, therefore allowing more detailed examination. There are many possible uses for this new tool, such as to examine mathematical expressions with very irregular shapes, to aid teaching people with impaired vision, to create raised relief maps from digital elevation maps (DEMs), to bridge the gap between mathematical tools and rapid prototyping, and many more. Ian Walker created the function r2stl() and Jose' Gama assembled the package. |
Authors: | Ian Walker [aut], Jose' Gama [aut], Paul J. Northrop [cre, ctb] |
Maintainer: | Paul J. Northrop <p.northrop@ucl.ac.uk> |
License: | CC BY-SA 4.0 |
Version: | 1.0.3 |
Built: | 2025-02-10 02:57:21 UTC |
Source: | https://github.com/paulnorthrop/r2stl |
r2stl
takes numeric input exactly as with the persp
function. The output is a STL (stereolithography) file.
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 )
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 )
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 |
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/.
The object returned when close
is used to close the
connection to filename
.
Ian Walker.
# 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)
# 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)