The challenge of plotting a function of three variables when all we have
to use for the display is two dimensions is twofold. First, we have to
introduce some sort of perspective, to determine what a three dimensional
image would look like to a given viewer, and then display that image.
Second, we have to incorporate the effect of what you see nearby and far
away. This is done in this applet by treating the density as if it were
a radiating gas, where the gas was capable of both giving off light and
absorbing light. The problem is known as the radiative transfer problem,
and is a common problem in astronomy, where one needs to understand the
light that we see from stars after the light has traveled both through the
layers of a star and the intervening interstellar medium.
Algorithm
The algorithm used to visualize these density plots is called ray tracing.
The density being plotted is assumed to give off light in proportion
to the value of the density. It is also assumed to absorb light in
proportion to its density, according to Beer's law. For each line of sight
in the image, the cumulative effect is calculated, turned into a color,
and plotted on the screen.