Plot a polygon.
Usage
plotPolygon3D(
pts,
useShade = TRUE,
useLines = FALSE,
usePoints = FALSE,
useFrame = TRUE,
...
)
Arguments
- pts
Vertices.
- useShade
Plot shade of the polygon.
- useLines
Plot lines inside the polygon.
- usePoints
Plot point shapes inside the polygon.
- useFrame
Plot a frame around the polygon.
- ...
Further arguments passed on the RGL plotting functions. This must be done as lists (see examples). Currently the following arguments are supported:
argsShade
: A list of arguments forrgl::polygon3d
(n > 4 vertices),rgl::triangles3d()
(n = 3 vertices) andrgl::quads3d()
(n = 4 vertices) ifuseShade = TRUE
.argsFrame
: A list of arguments forrgl::lines3d
ifuseFrame = TRUE
.argsPoints
: A list of arguments forrgl::shade3d
ifusePoints = TRUE
. It is important to give a texture usingtexture
. A texture can be set usinggetTexture()
.argsLines
: A list of arguments forrgl::persp3d()
whenuseLines = TRUE
. Moreover, the list may containlines
: number of lines.
Examples
# \donttest{
pts <- data.frame(x = c(1,0,0,0.4), y = c(0,1,0,0.3), z = c(0,0,1,0.3))
pts <- data.frame(x = c(1,0,0), y = c(0,1,0), z = c(0,0,1))
ini3D()
plotPolygon3D(pts)
finalize3D()
3D plot
ini3D()
plotPolygon3D(pts, argsShade = list(color = "red", alpha = 1))
finalize3D()
3D plot
ini3D()
plotPolygon3D(pts, useFrame = TRUE, argsShade = list(color = "red", alpha = 0.5),
argsFrame = list(color = "green"))
finalize3D()
3D plot
ini3D()
plotPolygon3D(pts, useFrame = TRUE, useLines = TRUE, useShade = TRUE,
argsShade = list(color = "red", alpha = 0.2),
argsLines = list(color = "blue"))
finalize3D()
3D plot
ini3D()
ids <- plotPolygon3D(pts, usePoints = TRUE, useFrame = TRUE,
argsPoints = list(texture = getTexture(pch = 16, cex = 20)))
finalize3D()
3D plot
# pop3d(id = ids) # remove object again
# In general you have to finetune size and numbers when you use textures
# Different pch
for (i in 0:3) {
fname <- getTexture(pch = 15+i, cex = 30)
ini3D(TRUE)
plotPolygon3D(pts, usePoints = TRUE, argsPoints = list(texture = fname))
finalize3D()
}
# Size of pch
for (i in 1:4) {
fname <- getTexture(pch = 15+i, cex = 10 * i)
ini3D(TRUE)
plotPolygon3D(pts, usePoints = TRUE, argsPoints = list(texture = fname))
finalize3D()
}
# Number of pch
fname <- getTexture(pch = 16, cex = 20)
for (i in 1:4) {
ini3D(TRUE)
plotPolygon3D(pts, usePoints = TRUE,
argsPoints = list(texture = fname, texcoords = rbind(pts$x, pts$y, pts$z)*5*i))
finalize3D()
}
# }