# Three-Dimensional Graphics Primitives

One of the most powerful aspects of graphics in *Mathematica* 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*.

Point[{x,y,z}] | point with coordinates x, y, z |

Line[{{x_{1},y_{1},z_{1}},{x_{2},y_{2},z_{2}},...}] | line through the points , , ... |

Polygon[{{x_{1},y_{1},z_{1}},{x_{2},y_{2},z_{2}},...}] | |

filled polygon with the specified list of corners | |

Cuboid[{x_{min},y_{min},z_{min}},{x_{max},y_{max},z_{max}}] | |

cuboid | |

Arrow[{pt_{1},pt_{2}}] | arrow pointing from to |

Text[expr,{x,y,z}] | text at position (see "Graphics Primitives for Text") |

Three-dimensional graphics elements.

In[1]:= |

In[2]:= |

In[3]:= |

Out[3]= |

In[4]:= |

Out[4]= |

If you give a list of graphics elements in two dimensions, *Mathematica* simply draws each element in turn, with later elements obscuring earlier ones. In three dimensions, however, *Mathematica* 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.

In[5]:= |

In[6]:= |

Out[6]= |

In[7]:= |

Out[7]= |

By creating an appropriate list of polygons, you can build up any three-dimensional object in *Mathematica*. Thus, for example, all the surfaces produced by ParametricPlot3D are represented essentially as lists of polygons.

Point[{pt_{1},pt_{2},...}] | a multipoint consisting of points at , , ... |

Line[{line_{1},line_{2},...}] | a multiline consisting of lines , , ... |

Polygon[{poly_{1},poly_{2},...}] | a multipolygon consisting of polygons , , ... |

Primitives which can take multiple elements.

As with the two-dimensional primitives, some three-dimensional graphics primitives have multi-coordinate forms, which are a more efficient representation. When dealing with a very large number of primitives, using these multi-coordinate forms where possible can both reduce the memory footprint of the resulting graphic and make it render much more quickly.

In[8]:= |

In[9]:= |

Out[9]= |

*Mathematica* allows polygons in three dimensions to have any number of vertices in any configuration. Depending upon the locations of the vertices, the resulting polygons may be non-coplanar or nonconvex. When rendering non-coplanar polygons, *Mathematica* will break the polygon into triangles, which are planar by definition, before rendering it.

In[10]:= |

Out[10]= |

In[11]:= |

Out[11]= |

Cone[{{x_{1},y_{1},z_{1}},{x_{2},y_{2},z_{2}}}] | a cone with a base radius of 1 centered around with the point at |

Cone[{{x_{1},y_{1},z_{1}},{x_{2},y_{2},z_{2}}},r] | a cone with a base radius of r |

Cuboid[{x,y,z}] | a unit cube with opposite corners having coordinates and |

Cuboid[{x_{min},y_{min},z_{min}},{x_{max},y_{max},z_{max}}] | a cuboid (rectangular parallelepiped) with opposite corners having the specified coordinates |

Cylinder[{{x_{1},y_{1},z_{1}},{x_{2},y_{2},z_{2}}}] | a cylinder of radius 1 with endpoints at and |

Cylinder[{{x_{1},y_{1},z_{1}},{x_{2},y_{2},z_{2}}},r] | a cylinder of radius r |

Sphere[{x,y,z}] | a unit sphere centered at |

Sphere[{x,y,z},r] | a sphere of radius r |

Tube[{{x_{1},y_{1},z_{1}},{x_{2},y_{2},z_{2}},...}] | a tube connecting the specified points |

Tube[{{x_{1},y_{1},z_{1}},{x_{2},y_{2},z_{2}},...},r] | a tube of radius r |

In[12]:= |

Out[12]= |

Even though Cone, Cylinder, Sphere, and Tube produce high-quality renderings, their usage is scalable. A single image can contain thousands of these primitives. When rendering so many primitives, you can increase the efficiency of rendering by using special options to change the number of points used by default to render Cone, Cylinder, Sphere, and Tube. The Method option to Graphics3D is used to reduce the rendering quality of each individual cone. Cylinder, sphere, and tube quality can be similarly adjusted using , , and , respectively.

In[13]:= |

Out[13]= |