[EDIT:更通用的解决方案可以在答案中看到这个问题]
我想知道是否有人可以帮助我使用 XYZ 坐标绘制球体表面的近似值。我尝试使用该包计算 Delaunay 三角面板geometry
然后用rgl
。第一次尝试看起来不错,但不幸的是创建了穿过球体的 Delaunay 3d 三角形。我最终只想绘制表面:
生成球体的 3d xyz 数据
n <- 10
rho <- 1
theta <- seq(0, 2*pi,, n) # azimuthal coordinate running from 0 to 2*pi
phi <- seq(0, pi,, n) # polar coordinate running from 0 to pi (colatitude)
grd <- expand.grid(theta=theta, phi=phi)
x <- rho * cos(grd$theta) * sin(grd$phi)
y <- rho * sin(grd$theta) * sin(grd$phi)
z <- rho * cos(grd$phi)
xyzw <- cbind(x,y,z,w=1)
计算 3d Delaunay 三角形并用 rgl 绘图:
#install.packages("geometry")
library(geometry)
library(rgl)
tc <- delaunayn(xyzw[,1:3])
open3d()
tetramesh(tc,cbind(x,y,z), alpha=0.2, col=5)
rgl.snapshot("3d_delaunay.png")
尝试通过 2d Delaunay 三角剖分仅返回表面三角形
tc <- delaunayn(xyzw[,c(1:2)])
open3d()
for(i in seq(nrow(tc))){
vertices <- c(t(xyzw[tc[i,],]))
indices <- c( 1, 2, 3)
shade3d( tmesh3d(vertices,indices) , alpha=0.2, col="cyan")
}
rgl.snapshot("2d_delaunay.png")
显然,有些东西不起作用。任何帮助将不胜感激。