# Error message: Coordinate index 0 is out of range for the enclosing GraphicsComplex

I am unable understand following error message: Coordinate index 0 is out of range for the enclosing GraphicsComplex. How to fix it?

 Graphics3D[GraphicsComplex[pts, Polygon@poly], Boxed -> False]


returns following error :

 Coordinate index 0 is out of range for the enclosing GraphicsComplex.


Data:

pts={{0, 1, 2}, {1, 0, 3}, {4, 5, 6}, {5, 4, 7}, {8, 9, 10}, {9, 8,
11}, {12, 13, 14}, {13, 12, 15}, {16, 17, 18}, {17, 16, 19}, {20,
21, 22}, {21, 20, 23}, {24, 25, 26}, {25, 24, 27}, {28, 29,
30}, {29, 28, 31}};

polys= {{0, 1, 2}, {1, 0, 3}, {4, 5, 6}, {5, 4, 7}, {8, 9, 10}, {9, 8,
11}, {12, 13, 14}, {13, 12, 15}, {16, 17, 18}, {17, 16, 19}, {20,
21, 22}, {21, 20, 23}, {24, 25, 26}, {25, 24, 27}, {28, 29,
30}, {29, 28, 31}};

-
The second argument to GraphicsComplex should be an expression where numbers represent the corresponding point in the first argument (based on index position). Mathematica indexes starting at 1 (0 is the Head), so you can't refer to index 0 because it doesn't exist. Also, Length@coord is only 24, so you shouldn't have numbers higher than 24 in poly, and you shouldn't have triplets since the numbers in poly should be indexes. – mfvonh Jun 25 '14 at 3:05

Note: this response was written before sample data for the question was changed from 24 3D points to 96 2D points. The main message remains unchanged, however.

The error message is complaining that the first zero in the first polygon specification is not a valid index into the list coord which has 24 elements.

A GraphicsComplex defines a list of points of interest. Inside the GraphicsComplex, point specifications must take the form of an index in that list. For example, we can draw a polygon whose corners are the first three points in coord like this:

Graphics3D[GraphicsComplex[coord, Polygon@{1, 2, 3}], Boxed -> False]


Note how each point specification is a simple integer, not the usual triple of coordinates.

Lists of integers are permitted, like this:

Graphics3D[GraphicsComplex[coord, Polygon@{{1, 2, 3}, {4, 5, 6}}], Boxed -> False]


However, the meaning of this construct is to draw two polygons: one whose corners are the first three points from coord and another whose corners are the second three points.

Since coord has 24 elements, only the indices 1 through 24 are permissible. In the example shown in the question, there are indices outside of this range. The error message is complaining about the first zero in the first polygon definition.

-
The data has changed, but the principle is the same. poly contains zero-based indices (0-95) but they must be one-based (1-96). The simplest corrective action is something like Graphics[GraphicsComplex[coord, Polygon[poly + 1]]]. However, I find it suspicious that poly contains degenerate polygons with coincident corners (e.g. {0, 0, 0} or {1, 0, 1}). – WReach Jun 25 '14 at 3:53
Well, now there is no data. Now let's see what you do! – acl Jul 14 '14 at 22:37
@acl you may remove this comment, I found it useless. – User12309 Jul 23 '14 at 20:54