Example Anaglyphs

T J Atherton, Tufts University

The Anaglyph package allows you to make a 3D image, called an anaglyph, from any Graphics3D object. Please install the package before running this notebook. To view the anaglyphs, you’ll need a pair of Red/Cyan 3D glasses. More information can be found on the Soft Matter Theory group’s website.

Needs["Anaglyph`"]

Plot3D

To turn the result of a conventional Plot3D into an anaglyph suitable with 3D glasses, simple use the Anaglyph function with default options. The use of SphericalRegion

Here’s the plot before:

Plot3D[Sin[x y],{x,0,2Pi},{y,0,2Pi}]

And here' s the anaglyph:

Anaglyph[Plot3D[Sin[x y],{x,0,2Pi},{y,0,2Pi}]]

Because the Anaglyph package converts the plot to an Image, you can no longer automatically rotate and zoom the graph. A workaround is to use a Manipulate as follows:

Manipulate[Anaglyph[Show[Plot3D[Sin[x y],{x,0,2Pi},{y,0,2Pi}],Axes-> False,ViewPoint-> R{Cos[θ]Cos[ϕ],Cos[θ]Sin[ϕ],Sin[θ]}]],{{θ,0.61,"Polar angle"},-Pi/2, Pi/2},{{ϕ,5.18,"Azimuthal angle"},0,2Pi},{{R,3.38,"Distance"},1,10},SaveDefinitions-> True,LocalizeVariables->True]

Anaglyph Options

The Anaglyph function takes a number of options, which are explained in the examples below:

Method

Method controls the coloring applied to the Anaglyph. True color anaglyphs are not possible because of the Red/Cyan filters in the glasses which only let through a portion of the visible spectrum respectively. Three possible settings are provided:

FullColor — Anaglyph tries to preserve all color information present in the image. This may result in an image that is uncomfortable to view because the brightness levels of an object in the left and right eye are mismatched. 

HalfColor — Anaglyph reduces the color by putting a grayscale into the left eye and the Blue component into the right eye. The color is distorted, but the image is typically more comfortable to view.

Optimized — A compromise position between preserving as much color as possible and balancing brightness appearance between eyes. This is the default setting. Strong Red and Blue objects will appear recolored; images with green/purple/yellow will appear with realistic color. 

Different images may look better with different methods, so you’re encouraged to play with this option.

Manipulate[Anaglyph[Plot3D[Sin[x y],{x,0,2Pi},{y,0,2Pi}],Method-> method],{method,{"Optimized","FullColor","HalfColor"}},SaveDefinitions-> True]

ViewAngleDifference

This option controls the strength of the stereoscopic effect. About 2 degrees is typically a comfortable value.

Manipulate[Anaglyph[Plot3D[Sin[x y],{x,0,2Pi},{y,0,2Pi}],ViewAngleDifference-> α Degree],{{α,2,"ViewAngleDifference"},0,5},SaveDefinitions-> True]

ImageSize

This option controls the size of the produced image—useful for preparing print quality versions.

Anaglyph[Plot3D[Sin[x y],{x,0,2Pi},{y,0,2Pi}],ImageSize-> 200]

Further Examples

Explore polyhedra

Manipulate[Anaglyph[Graphics3D[{Yellow,Opacity[0.3],PolyhedronData[polyhedron,"Faces"]}]],{{polyhedron,"TruncatedIcosahedron"},Select[PolyhedronData[],StringQ]}]

Try different color schemes to find an effective combination for your Anaglyph:

Manipulate[Grid[{{Anaglyph[Plot3D[Sin[x y],{x,0,3},{y,0,3},ColorFunction->colorscheme,Mesh->None]],Plot3D[Sin[x y],{x,0,3},{y,0,3},ColorFunction->colorscheme,Mesh->None]}}],{colorscheme,ColorData["Gradients"]}]

Using ParametricPlot3D to visualize a surface

Γ[θ_,ϕ_,e_,μ_]:={((μ (e-Cos[θ] Cos[ϕ])+(1-(e^2)) Cos[θ])/(1-e Cos[θ] Cos[ϕ])),(((Sqrt[1-(e^2)]) Sin[θ] (1-μ Cos[ϕ]))/(1-e Cos[θ] Cos[ϕ])),(((Sqrt[1-(e^2)]) Sin[ϕ] (e Cos[θ]-μ))/(1-e Cos[θ] Cos[ϕ]))};
Anaglyph[ParametricPlot3D[Γ[θ, ϕ,0.2, 1], {θ,0,2 Pi},{ϕ,0, 2 Pi}, Boxed-> False,Axes-> False,Mesh-> True]]

Combining Manipulate and ContourPlot3D, together with Opacity, gives a new insight into the shape of this surface

Manipulate[Anaglyph[ContourPlot3D[x^4+y^4+z^4-(x^2+y^2+z^2)^2+3(x^2+y^2+z^2)==L,{x, -2,2}, {y, -2, 2}, {z, -2, 2},Mesh->None,ContourStyle->Directive[Gray,Opacity[0.6],Specularity[White,30]],ViewPoint-> R{Cos[θ]Cos[ϕ],Cos[θ]Sin[ϕ],Sin[θ]}]],{L,1,5},Delimiter,{{θ,Pi/3,"Polar angle"},0, Pi},{{ϕ,Pi/3,"Azimuthal angle"},0,2Pi},{{R,5,"Distance"},5,10}]

The Spherical Harmonics are very difficult to picture without a 3D object to play with

Manipulate[Anaglyph[Quiet[SphericalPlot3D[Abs[SphericalHarmonicY[l,m,theta,phi]],{theta,0,Pi},{phi,0,2Pi},PlotStyle->Directive[LightBlue,Opacity[0.8],Specularity[White,10]],ViewPoint-> R{Cos[θ]Cos[ϕ],Cos[θ]Sin[ϕ],Sin[θ]},Mesh->None,PlotPoints->30,Boxed-> False,Axes-> False]]],{{l,0,"Polar quantum number l"},0,5,1},{{m,0,"Azimuthal quantum number m"},-l,l,1},Delimiter,{{θ,Pi/3,"Polar angle"},0, Pi},{{ϕ,Pi/3,"Azimuthal angle"},0,2Pi},{{R,5,"Distance"},5,10},SaveDefinitions-> True]

Visualize chemical structures

Manipulate[Anaglyph[Show[ChemicalData["Caffeine","MoleculePlot"],ViewPoint-> R{Cos[θ]Cos[ϕ],Cos[θ]Sin[ϕ],Sin[θ]}]],{{θ,Pi/3,"Polar angle"},0, Pi},{{ϕ,Pi/3,"Azimuthal angle"},0,2Pi},{{R,5,"Distance"},5,10}]