2011-06-26 70 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