Learn R Programming

PolygonSoup (version 1.0.1)

plotEdges: Plot some edges

Description

Plot the given edges with rgl.

Usage

plotEdges(
  vertices,
  edges,
  color = "black",
  lwd = 2,
  edgesAsTubes = TRUE,
  tubesRadius = 0.03,
  verticesAsSpheres = TRUE,
  only = NULL,
  spheresRadius = 0.05,
  spheresColor = color
)

Value

No value.

Arguments

vertices

a three-columns matrix giving the coordinates of the vertices

edges

a two-columns integer matrix giving the edges by pairs of vertex indices

color

a color for the edges

lwd

line width, a positive number, ignored if edgesAsTubes=TRUE

edgesAsTubes

Boolean, whether to draw the edges as tubes

tubesRadius

the radius of the tubes when edgesAsTubes=TRUE

verticesAsSpheres

Boolean, whether to draw the vertices as spheres

only

integer vector made of the indices of the vertices you want to plot (as spheres), or NULL to plot all vertices

spheresRadius

the radius of the spheres when verticesAsSpheres=TRUE

spheresColor

the color of the spheres when verticesAsSpheres=TRUE

Examples

Run this code
library(PolygonSoup)
library(rgl)

# we triangulate the truncated icosahedron mesh
mesh <- Mesh(
  mesh = truncatedIcosahedron,
  triangulate = TRUE, normals = FALSE
)
# now we can plot the truncated icosahedron
tmesh <- toRGL(mesh)
open3d(windowRect = c(50, 50, 562, 562), zoom = 0.9)
shade3d(tmesh, color = "gold")
# we plot the edges given in `mesh[["edges0"]]`; these are the 
# edges of the mesh before the triangulation
plotEdges(mesh[["vertices"]], mesh[["edges0"]], color = "navy")

# we triangulate the pentagrammic prism mesh
mesh <- Mesh(
  mesh = pentagrammicPrism,
  triangulate = TRUE, normals = FALSE
)
# now we can plot the pentagrammic prism
tmesh <- toRGL(mesh)
open3d(windowRect = c(50, 50, 562, 562), zoom = 0.9)
shade3d(tmesh, color = "navy")
# we plot the exterior edges only, given in `mesh[["exteriorEdges"]]`
plotEdges(
  mesh[["vertices"]], mesh[["exteriorEdges"]], color = "gold",
  tubesRadius = 0.02, spheresRadius = 0.02
)

# or only plot the edges whose corresponding dihedral angle is acute:
allEdges <- mesh[["edgesDF"]]
edges <- as.matrix(subset(allEdges, angle <= 91, select = c("i1", "i2")))

Run the code above in your browser using DataLab