2011-06-26 74 views
7

考虑以下几点:在Mathematica中使用图形显示多个2D图形?

lalist = {{{{1, 1}, 1}, {{3, 3}, 1}, {{5, 5}, 1}}, 
      {{{1, 5}, 1}, {{3, 3}, 1}, {{5, 1}, 1}}} 

enter image description here

Row[{ 
    Graphics[{ 
      Opacity[0.5],Red, 
      Disk @@@ lalist[[1]]}, 
      Frame -> True], 
    Graphics[{ 
      Opacity[0.5],Blue, 
      Disk @@@ lalist[[2]]}, 
      Frame -> True]} 
    ] 

enter image description here

  • 难道我绘制蓝军 磁盘 “背后” 红色的在3 d 情节?

下面是不是我所需要:

enter image description here

回答

10

喜欢这个?

Graphics3D[{{Texture[ 
Graphics[{Opacity[0.5], Blue, Disk @@@ lalist[[2]]}, 
    Frame -> True]], 
Polygon[{{-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}}, 
VertexTextureCoordinates \[Rule] {{0, 0}, {1, 0}, {1, 1}, {0, 
    1}}]}, {Texture[ 
Graphics[{Opacity[0.5], Red, Disk @@@ lalist[[1]]}, 
    Frame -> True]], 
Polygon[{{-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1}}, 
VertexTextureCoordinates \[Rule] {{0, 0}, {1, 0}, {1, 1}, {0, 
    1}}]}}, Lighting \[Rule] "Neutral"] 

enter image description here

很多很多的不透明度1.2:

tab = Table[{Opacity \[Rule] .2, 
Texture[Graphics[{Opacity[0.5], Blue, Disk @@@ lalist[[2]]}, 
    Frame -> True]], 
Polygon[{{-1, -1, z}, {1, -1, z}, {1, 1, z}, {-1, 1, z}}, 
VertexTextureCoordinates \[Rule] {{0, 0}, {1, 0}, {1, 1}, {0, 
    1}}]}, {z, -2, 2, 1}]; 
plt = Graphics3D[{tab}, Lighting \[Rule] "Neutral"] 

enter image description here

和400似乎并没有太大的问题,在速度方面(你可以轻松修改上面的代码来查看它)。

编辑:好的,我傻了,试试这个

Dynamic[Graphics3D[{{Texture[#], 
    Polygon[{{-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}}, 
    VertexTextureCoordinates \[Rule] {{0, 0}, {1, 0}, {1, 1}, {0, 
     1}}]}, {Texture[Rotate[#, \[Pi]/2]], 
    Polygon[{{-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1}}, 
    VertexTextureCoordinates \[Rule] {{0, 0}, {1, 0}, {1, 1}, {0, 
     1}}]}}, Lighting \[Rule] "Neutral"] &@Binarize[CurrentImage[]]] 

这给

enter image description here

(或类似的东西),旋转,实时更新等

+0

@acl,对不起,没有我,我真的想3D情节:)我怎么能更好地表达我的问题? – 500

+0

@acl,是的,你认为它可以处理400个:)? – 500

+0

@ 500只有一种方法找出:)如果它不问这里... – acl

4

使用透明纹理来分层渲染这些圆as ACL does是一个很好的解决方案,除非有人想要与生成的3D对象进行交互。 Rendering of 3D objects that contain transparent elements is done in software whereas otherwise it would have been done in hardware

3D渲染器使用两种不同的 排序多边形的方法。对于不包含 透明度的 图形场景,使用硬件加速的 深度缓冲区。否则, 渲染器使用二进制空间分区 树对任意视点的多边形进行分割和排序。 BSP树的制作速度较慢,而不是硬件 加速,但它提供了支持多边形的一般能力。

在我的笔记本电脑上,只要透明物体开始出现,与3D图形的交互就非常慢。

解决方法是使用3D磁盘而不是半透明平面与2D磁盘。由于MMA没有3D Disk s或Circle s,如果您想要做这样的事情,您必须推出自己的。裸骨版本会是这样的:

myDisk[{x_, y_, z_}, r_] := 
[email protected][ 
       {x, y, z} + r {Cos[\[Phi]], Sin[\[Phi]], 0} // N, 
       {\[Phi], 0, 2 \[Pi], 2 \[Pi]/200} 
       ] 

您层将作为然后可以产生如下:

Graphics3D[ 
{ 
    EdgeForm[], 
    { 
    Red, 
    myDisk[{1, 1, 0.5}, 0.5], 
    myDisk[{0, 0, 0.5}, 0.5], 
    myDisk[{-1, -1, 0.5}, 0.5] 
    }, 
    { 
    Blue, 
    myDisk[{1, -1, -0.5}, 0.5], 
    myDisk[{0, 0, -0.5}, -0.5], 
    myDisk[{-1, 1, -0.5}, 0.5]} 
    } 
] 

enter image description here

+0

啊,但我的多边形有我的脸! – acl

+0

@ACL是的,我也试过你的代码。使一些犯罪看,相当无法辨认的肖像。非常适合头像。 (你穿高领毛衣和胡子,BTW?) –

+0

在任何情况下你都是对的,即使在我的MacBook上使用它的可怜的图形卡,“不透明度”确实会减慢速度。 – acl