【发布时间】:2023-03-30 23:37:02
【问题描述】:
我有一个多边形,我想将其转换为一个圆柱形 3D 对象以进行说明:
x <- structure(list(x = c(7.99, 6.25, -1.77, -1.8, -0.48, 3.93, 7.99
), y = c(2.84, 2.31, 2.43, 2.98, 3.19, 3.26, 2.84)), row.names = c(NA,
7L), class = "data.frame")
plot(x$x, x$y, type = "n")
polygon(x$x, x$y, col = "blue")
points(x$x, x$y)
我无法理解如何添加值为 2 和 5 的 z 轴,例如:
library(rgl)
lines3d(x = rep(x$x, 2), y = rep(x$y, 2), z = rep(c(2, 5), each = nrow(x)))
我想让面孔着色和连接。类似于cylinders on Wikipedia illustrations,但自然不是圆形末端,而是那些多边形。如果我使用 rgl 包,我应该使用tringles3d 或polygon3d 函数,但我不明白如何重构我的data.frame。我不需要在 rgl 中执行此操作。这只是似乎最适合这项任务的 R 包。我应该如何重新组织我的数据来绘制 3D 圆柱体?
【问题讨论】: