Hi,
This is an idea that has challenged me since I started using MMA a little over two years ago. The idea was to append //stereo
to a 3D plot and instantly get a stereogram that can be manipulated just like a normal 3D plot, turning it around and viewing it from different angles. This is my first use of Dynamic
, so it might be a little clunky. Help in speeding it up would be appreciated.
stereo[expr_] := DynamicModule[
{vp = {1.3, -2.4, 2.0}, vv = {0., 0., 2.0}, plot},
plot = expr;
GraphicsRow[
{Show[plot, ViewPoint -> Dynamic[vp + {0.4, 0, 0}], ViewVertical -> Dynamic[vv]],
Show[plot, ViewPoint -> Dynamic[vp], ViewVertical -> Dynamic[vv]]},
ImageSize -> Large
]
]
For instance,
Plot3D[Sin[x] Cos[y] Cos[x y], {x, 0, 2 Pi}, {y, 0, 2 Pi},
PlotRange -> All, ColorFunction -> "BlueGreenYellow"] // stereo

Viewing the stereogram takes a little practice. I learned it from a radiologist who used it to make 3D X-rays. He would position the patient, take an x-ray, move the x-ray source over a couple of inches, and take another x-ray. Then he put both x-rays side-by-side on the light panel, stepped back, and crossed his eyes until the two images superimposed. Voila! a 3D view of the interior of patient's body.
When learning, it's helpful to hold a finger between your eyes and the image. Focus on the finger and move it back and forth until the images coalesce in the background. Now keep the images together and re-focus your eyes on them. That can be tricky as it's quite unnatural.
Once the trick is learned, stereo images are as easy to see as flat ones.
The right-hand image can be moved around using the mouse and the left will follow.
The function needs improvement, though. Sometimes the images get out of sync. Just do a shift-enter to restart.
Eric
EDIT: I've changed the offset in the viewpoint from {0,0.4,0} to {0.4,0,0}. Strange how even the wrong offset results in a stereogram!