【发布时间】:2019-07-15 21:58:00
【问题描述】:
我想使用 arcos 变换在 R 中绘制一个球体,其表面上的网格线对应于球体的等面积网格。
我一直在试验 R packakge rgl 并得到了一些帮助: Plot points on a sphere in R
它以相等的纬度和长间距绘制网格线。
我有下面的函数,它返回一个点数据框,这些点是我想要的网格线的交叉点,但不知道如何继续。
plot_sphere <- function(theta_num,phi_num){
theta <- seq(0,2*pi,(2*pi)/(theta_num))
phi <- seq(0,pi,pi/(phi_num))
tmp <- seq(0,2*phi_num,2)/phi_num
phi <- acos(1-tmp)
tmp <- cbind(rep(seq(1,theta_num),each = phi_num),rep(seq(1,phi_num),times = theta_num))
results <- as.data.frame(cbind(theta[tmp[,1]],phi[tmp[,2]]))
names(results) <- c("theta","phi")
results$x <- cos(results$theta)*sin(results$phi)
results$y <- sin(results$theta)*sin(results$phi)
results$z <- cos(results$phi)
return(results)
}
sphere <- plot_sphere(10,10)
谁能帮忙,总的来说,我发现 rgl 函数很难使用。
【问题讨论】:
标签: r plot 3d latitude-longitude rgl