Learn R Programming

cgalMeshes (version 2.2.0)

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,
  spheresRadius = 0.05,
  spheresColor = color
)

Value

No value, just produces a 3D graphic.

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

spheresRadius

the radius of the spheres when verticesAsSpheres=TRUE

spheresColor

the color of the spheres when verticesAsSpheres=TRUE

Examples

Run this code
library(cgalMeshes)
library(rgl)

mesh <- cgalMesh$new(pentagrammicPrism, clean = FALSE)
vertices <- mesh$getVertices()
edges <- mesh$getEdges()
extEdges <- exteriorEdges(edges)
tmesh <- mesh$triangulate()$getMesh()

open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.9)
shade3d(tmesh, color = "navy")
# we plot the exterior edges only
plotEdges(
  vertices, extEdges, color = "gold",
  tubesRadius = 0.02, spheresRadius = 0.02
)

# or only plot the edges whose corresponding dihedral angle is acute:
sharpEdges <- as.matrix(subset(edges, angle <= 91, select = c("i1", "i2")))
open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.9)
shade3d(tmesh, color = "maroon")
plotEdges(
  vertices, sharpEdges, color = "darkred", 
  tubesRadius = 0.02, spheresRadius = 0.02
)

Run the code above in your browser using DataLab