MATHEMATICA TUTORIAL

# Efficient Representation of Many Primitives

 Point[{pt1,pt2,...}] a multipoint consisting of points at , , ... Line[{line1,line2,...}] a multiline consisting of lines , , ... Polygon[{poly1,poly2,...}] a multipolygon consisting of polygons , , ...

Primitives which can take multiple elements.

Some primitives have multi-element forms that can be processed and rendered more quickly by the Mathematica front end than the equivalent individual primitives. For large numbers of primitives, using the multi-element forms can also significantly reduce the sizes of notebook files. Notebooks that use multi-element forms can be less than half the size of those that do not, and render up to ten times faster.

Here is a multipoint random distribution.
 Out[1]=
 GraphicsComplex[{pt1,pt2,...},data] a graphics complex in which coordinates given as integers i in graphics primitives in data are taken to be

Primitive for sharing coordinate data among primitives.

When many primitives share the same coordinate data, as in meshes and graphs, further efficiency can be gained by using GraphicsComplex to factor out the coordinate data. The output of Mathematica's surface- and graph-plotting functions typically use this representation.

Here is a structure of points and lines that share coordinates.
 Out[2]=

In addition to being efficient, GraphicsComplex is useful interactively. Primitives that share coordinates stay connected when one of them is dragged.

Because the output of GraphPlot is a GraphicsComplex, the graph stays connected when any part of it is dragged.
 Out[3]=

Any primitive may be used within a GraphicsComplex, and GraphicsComplex can be used in both 2D and 3D graphics. Within GraphicsComplex, coordinate positions in primitives are replaced by indices into the coordinate data in the GraphicsComplex.

This GraphicsComplex combines several types of primitives.
 Out[4]=

GraphicsComplex is especially useful for representing meshes of polygons. By using GraphicsComplex, numerical errors that could cause gaps between adjacent polygons are avoided.

The output of Plot3D is a GraphicsComplex.
 Out[5]=

## Tutorial CollectionTutorial Collection

New to Mathematica? Find your learning path »
Have a question? Ask support »