Re: [Mathematica 6]3 lines of code which crashes Mathematica every time
- To: mathgroup at smc.vnet.net
- Subject: [mg76538] Re: [mg76449] [Mathematica 6]3 lines of code which crashes Mathematica every time
- From: John Fultz <jfultz at wolfram.com>
- Date: Wed, 23 May 2007 05:41:18 -0400 (EDT)
- Reply-to: jfultz at wolfram.com
On Tue, 22 May 2007 02:57:02 -0400 (EDT), Nasser Abbasi wrote:
>
>
> (* WARNING, SAVE ALL YOUR WORK BEFORE RUNNING THIS *)
>
> m = 100; n = 70;
> A = Table[Table[RandomReal[{0, 100.}], {n}], {m}];
> ListPlot3D[A, Mesh -> None, InterpolationOrder -> 0, ColorFunction ->
> "SouthwestColors", Filling -> Axis]
>
>
> (*Now Mathematica will spin for sometime then disappear.*)
>
> Nasser
The killer here is Filling->Axis. Using Filling introduces more polygons,=
which
doesn't help, but the big problem is that the default FillingStyle=
introduces
transparency into the graphic. Removing the Filling, or keeping the Filling=
but
not using a transparent FillingStyle, e.g.,
m = 70; n = 100;
A = Table[Table[RandomReal[{0, 100.}], {n}], {m}];
ListPlot3D[A, Mesh -> None, InterpolationOrder -> 0,
ColorFunction -> "SouthwestColors", Filling -> Axis,
FillingStyle -> Red ]
will make this work much better.
The transparency issue is a general one in 3D graphics. It arises because=
it's
algorithmically much more difficult to sort polygons (i.e. to know which
polygons are in front of which other polygons) when some of those polygons=
are
transparent. If you're at all familiar with polygon sorting algorithms,=
here's
a brief description of what we're doing.
We use Z-buffering to sort polygons when no transparency exists. Not only=
is it
simple and fast, modern video cards have hardware that speeds it up. If
transparent polygons are present, Z-buffering will produce bad results, so=
we
sort the polygons using a BSP tree, which is very efficient once created,=
but
the initial tree creation has a high cost. Also, the resulting BSP tree has=
many more polygons because of the necessity of splitting existing polygons.
In your example, there are so many polygons (particularly the ones that are=
created by splitting existing polygons) that simply creating the BSP tree
exhausts the available memory. With smaller values of m and n, the BSP tree=
could be created, but the rendering will still be much slower.
Sincerely,
John Fultz
jfultz at wolfram.com
User Interface Group
Wolfram Research, Inc.