Introduction to 3D graphics

Comprehension Questions

Math 250 - Mathematical Computing
Christopher Hanusa

10-1. Create a grid of spheres.

10-2. Create a square with some thickness.  It should look something like this:

10-3. Put spheres on the corners of your square from Question 2 using the Map command, similar to this:

10-4. Create three sides of a house using polygonal faces.

Hint 1: (expand to see)

First determine the coordinates of each of the corners of the faces.

Hint 2: (expand to see)

You can create one face of the tetrahedron in this way:

v1={0,0,0};
v2={0,0,1};
v3={0,1,1};
v4={0,1,0};

Graphics3D[Polygon[{v1,v2,v3,v4}]]

10-5. Create a tetrahedron using PolyhedronData.  Use one line of code.

10-6. Create an ice cream cone with three different flavors of ice cream, like this:

Hint 1: (expand to see)

Use the options Lighting->”Neutral” and Boxed->False to make the colors work correctly and to have no box around the final form.

Challenge Questions:

10-X1. Make your grid of spheres from Question 10-1 vary in size and color.

10-X2. Create a 3D grid that looks like this, analogous to the 2D grid we did in earlier tutorials:

Additional construction: Build your own polyhedra

If you want to create your own polyhedron, use GraphicsComplex by specifying the list of coordinates of all the vertices and then specifying which vertices connect to be a face of the object.
(Again, from the Documentation Center:)

vertices={{0,0,0},{2,0,0},{2,2,0},{0,2,0},{1,1,2}};
faces={{1,2,5},{2,3,5},{3,4,5},{4,1,5}};
Graphics3D[{Opacity[.8],Yellow,GraphicsComplex[vertices,Polygon[faces]]}]

Navigate to the Documentation Center entry for GraphicsComplex, and look at the “Properties & Relations” near the bottom.

10-X3. Create a square antiprism using GraphicsComplex.  To get you started, the coordinates of the vertices are given as well as the first three faces:

s=1/Sqrt[2];
APVertices={{1,0,0},{0,1,0},{-1,0,0},{0,-1,0},{s,s,1},{-s,s,1},{-s,-s,1},{s,-s,1}};
APFaces={{1,2,3,4},{5,6,7,8},{1,2,5}};
Graphics3D[{Opacity[.8],Yellow,GraphicsComplex[APVertices,Polygon[APFaces]]}]

Hint: (expand to see)

You may find it helpful to label the vertices:

s=1/Sqrt[2];
APVertices={{1,0,0},{0,1,0},{-1,0,0},{0,-1,0},{s,s,1},{-s,s,1},{-s,-s,1},{s,-s,1}};
APFaces={{1,2,3,4},{5,6,7,8},{1,2,5}};
Graphics3D[{Opacity[.8],Yellow,GraphicsComplex[APVertices,Polygon[APFaces]],{Black,MapThread[Style[Text[#1,#2],FontSize->20]&,{Range[8],APVertices}]}}]