f



3D visulaisation of 3D matrix for a 3D CA #2

Hi,

I have a 3D matrix, of the form 
{{{1, 2, 3, 4}, 
  {5, 6, 7, 8}, 
  {9, 10,11,12}, 
  {13,14,15,16}},
 {{17, 18, 19, 20},
  {21, 22, 23, 24},
  {25, 26, 27, 28},
  {29, 30, 31, 32}}}

I want to plot this matrix, where every number is a unit cube, to give a sort of 3D grid, where the number gives the colour. In reality most numbers would be 0, which would be transparent.

I want to do this as I'm developing a 3D partitioned cellular automaton, and have it defined over structures of this sort, and I want to be able to visualise its development. In 2D I've used MatrixPlot and Animate to do this.

One layer is 1-16, and the second is 17-32.

Any help would be greatly appreciated,

Thanks!

0
jongren
4/27/2010 8:03:51 AM
comp.soft-sys.math.mathematica 28821 articles. 0 followers. Follow

1 Replies
872 Views

Similar Articles

[PageSpeed] 22

On 27 Apr., 10:03, jongren <jongreno...@gmail.com> wrote:
> Hi,
>
> I have a 3D matrix, of the form
> {{{1, 2, 3, 4},
>   {5, 6, 7, 8},
>   {9, 10,11,12},
>   {13,14,15,16}},
>  {{17, 18, 19, 20},
>   {21, 22, 23, 24},
>   {25, 26, 27, 28},
>   {29, 30, 31, 32}}}
>
> I want to plot this matrix, where every number is a unit cube, to give a sort of 3D grid, where the number gives the colour. In reality most numbers would be 0, which would be transparent.
>
> I want to do this as I'm developing a 3D partitioned cellular automaton, and have it defined over structures of this sort, and I want to be able to visualise its development. In 2D I've used MatrixPlot and Animate to do this.
>
> One layer is 1-16, and the second is 17-32.
>
> Any help would be greatly appreciated,
>
> Thanks!

Hi,

you could try something similar to this:

Graphics3D[{Opacity[0.3],
  MapThread[{Hue[#1], Cuboid[#2]} &, {Flatten[mat/Max[mat], 2],
    Flatten[Array[2 {#1, #2, #3} &, Dimensions@mat], 2]}]}]

Cheers,

Markus

0
M
4/28/2010 6:00:00 AM
Reply: