填充 3D 图中两个线段之间的区域 {rgl} [英] Fill area between two segments in a 3D plot {rgl}

查看:29
本文介绍了填充 3D 图中两个线段之间的区域 {rgl}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 {rgl} 包中的函数 plot3d() 使用顶点坐标和线段制作了一个四面体.下面的代码使

I have made a tetrahedron using vertex coordinates and line segments using the function plot3d() from the package {rgl}. The code below makes the mentioned plot

library("rgl")
CCl4=c(5,5,5,10)
Luminol=c(0.01,0.001,0.005,0.005)
Na2CO3=c(0.01,0.01,0.1,0.05)

plot3d( Luminol, Na2CO3, CCl4, type = "s")

for(i in 1:4){
    for(k in 1:4){
                 segments3d(x=Luminol[c(i,k)],y=Na2CO3[c(i,k)],z=CCl4[c(i,k)])
                 }
        }

Now, I want to fill the area between the points (preferably using a RGB color so I can define transparency using an alpha value) but I have not found a polygon() like function in rgl. Is there a way to fill this area?

Thanks in advance.

解决方案

Is this what you are looking for? Wasn't completely clear on the request. I added color to everything to help figure it out.

library("rgl")
CCl4=c(5,5,5,10)
Luminol=c(0.01,0.001,0.005,0.005)
Na2CO3=c(0.01,0.01,0.1,0.05)

clrs <- c("red","blue","green","darkgrey")

plot3d( Luminol, Na2CO3, CCl4, type = "s",col=clrs)

for(i in 1:4){
  clr <- clrs[i]
  for(k in (i+1):4){
      v <- c(i,k)
      segments3d(Luminol[v],Na2CO3[v],CCl4[v],color=clr)
  }
}

for (i in 1:4){
  clr <- clrs[i]
  v <- setdiff(1:4,i)
  triangles3d(Luminol[v],Na2CO3[v],CCl4[v],alpha=0.5,col=clr)
}

yielding:

这篇关于填充 3D 图中两个线段之间的区域 {rgl}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆