开发者

Display multiple 2D plots in 3D using Graphics in Mathematica?

开发者 https://www.devze.com 2023-03-15 07:57 出处:网络
Considering the following 开发者_如何学JAVA: lalist = {{{{1, 1}, 1}, {{3, 3}, 1}, {{5, 5}, 1}}, {{{1, 5}, 1}, {{3, 3}, 1}, {{5, 1}, 1}}}

Considering the following 开发者_如何学JAVA:

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

Display multiple 2D plots in 3D using Graphics in Mathematica?

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

Display multiple 2D plots in 3D using Graphics in Mathematica?

  • Is it possible that I plot the Blues Disks "behind" the red ones in a 3 D plot ?

Below is not what I need :

Display multiple 2D plots in 3D using Graphics in Mathematica?


Like this?

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"]

Display multiple 2D plots in 3D using Graphics in Mathematica?

Lots of them with opacity .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"]

Display multiple 2D plots in 3D using Graphics in Mathematica?

and 400 don't seem to be much of a problem in terms of speed (you can easily modify the code above to see it).

EDIT: OK, just to be silly, try this

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[]]]

which gives

Display multiple 2D plots in 3D using Graphics in Mathematica?

(or something like that), rotatable, updated in real time etc.


See the solution presented on "Lunchtime Playground: Fun with Mathematica" here: http://mathgis.blogspot.com/2009/02/howto-display-2d-plot-in-3d.html


Using transparent textures to render these circles in layers as ACL does is a nice solution, unless one wants to interact with the resulting 3D object. Rendering of 3D objects that contain transparent elements is done in software whereas otherwise it would have been done in hardware:

The 3D renderer uses two different methods of sorting polygons. For graphics scenes that include no transparency, a hardware-accelerated depth buffer is used. Otherwise, the renderer uses a binary space partition tree to split and sort polygons from any viewpoint. The BSP tree is slower to create and is not hardware accelerated, but it provides the most general ability to support polygons.

On my laptop, interaction with 3D graphics is incredibly slow as soon as transparent objects start to appear.

The solution would be to use 3D disks instead of semi transparent planes with 2D disks in them. Since MMA doesn't have 3D Disks or Circles if you want to do something like that, you have to roll your own. A bare-bones version would be something like:

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

Your layers would then be generated as follows:

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]}
  }
 ]

Display multiple 2D plots in 3D using Graphics in Mathematica?

0

精彩评论

暂无评论...
验证码 换一张
取 消