Legacy Documentation

Mathematica® Teacher's Edition (2002)

This is documentation for an obsolete product.
Current products and services
 Documentation /  Mathematica Teacher's Edition /  The Teacher's Book /  Basic Calculations /  Three-Dimensional Graphics /

10.1 Three-Dimensional Graphics Primitives

One of the most powerful aspects of graphics in Mathematica TE is the availability of three-dimensional as well as two-dimensional graphics primitives. By combining three-dimensional graphics primitives, you can represent and render three-dimensional objects in Mathematica TE.

Three-dimensional graphics elements.

Every time you evaluate rcoord, it generates a random coordinate in three dimensions.

In[1]:= rcoord := {Random[ ], Random[ ], Random[ ]}

This generates a list of 20 random points in three-dimensional space.

In[2]:= pts = Table[Point[rcoord], {20}] ;

Here is a plot of the points.

In[3]:= Show[ Graphics3D[ pts ] ]

Out[3]=

This gives a plot showing a line through 10 random points in three dimensions.

In[4]:= Show[ Graphics3D[ Line[ Table[rcoord, {10}] ] ] ]

Out[4]=

If you give a list of graphics elements in two dimensions, Mathematica TE simply draws each element in turn, with later elements obscuring earlier ones. In three dimensions, however, Mathematica TE collects together all the graphics elements you specify, then displays them as three-dimensional objects, with the ones in front in three-dimensional space obscuring those behind.

Every time you evaluate rantri, it generates a random triangle in three-dimensional space.

In[5]:= rantri := Polygon[ Table[ rcoord, {3} ] ]

This draws a single random triangle.

In[6]:= Show[ Graphics3D[ rantri ] ]

Out[6]=

This draws a collection of five random triangles. The triangles in front obscure those behind.

In[7]:= Show[ Graphics3D[ Table[rantri, {5}] ] ]

Out[7]=

By creating an appropriate list of polygons, you can build up any three-dimensional object in Mathematica TE. Thus, for example, all the surfaces produced by ParametricPlot3D are represented simply as lists of polygons.
The package Graphics`Polyhedra` contains examples of lists of polygons that correspond to polyhedra in three dimensions.

This loads a package that defines various polyhedra.

In[8]:= <<Graphics`Polyhedra`;

Here is the list of the four polygons corresponding to a tetrahedron centered at the origin.

In[9]:= Tetrahedron[ ]

Out[9]=

This displays the tetrahedron as a three-dimensional object.

In[10]:= Show[ Graphics3D[ % ] ]

Out[10]=

Dodecahedron[ ] is another three-dimensional object defined in the polyhedra package.

In[11]:= Show[ Graphics3D[ Dodecahedron[ ] ] ]

Out[11]=

This shows four intersecting dodecahedra.

In[12]:= Show[ Graphics3D[
Table[Dodecahedron[0.8 {k, k, k}], {k, 0, 3}] ] ]

Out[12]=

Mathematica TE allows polygons in three dimensions to have any number of vertices. However, these vertices should lie in a plane, and should form a convex figure. If they do not, then Mathematica TE will break the polygon into triangles, which are planar by definition, before rendering it.

Cuboid graphics elements.

This draws 20 random unit cubes in three-dimensional space.

In[13]:= Show[Graphics3D[ Table[Cuboid[10 rcoord], {20}] ]]

Out[13]=