在 R 中可视化多面体

Visualize a polyhedron in R

我正在寻求可视化顶点为

的四面体
(0,0,0)
(2,sqrt(2),0)
(2,0,2)
(2,-sqrt(2),0)

R 中是否有一种内置(或打包)的方式来可视化它而无需手动绘制 edges/faces?

您可以使用 qmesh3d:

library(rgl)

vertices <- cbind(
  c(0,0,0),
  c(2,sqrt(2),0),
  c(2,0,2),
  c(2,-sqrt(2),0)
)

# Define the faces : in case of tetrahedron, all combinations of 3 vertices
indices <- combn(1:4,m = 3)

tetrahedron <- qmesh3d(
  vertices = vertices,
  indices = indices,
  homogeneous = FALSE
)

shade3d(tetrahedron, color = "grey", alpha = 0.1)
wire3d(tetrahedron, color = "blue")