private static int[][] triangulate(int[] sides) {
		boolean[] discard = new boolean[sides.length];

		List<int[]> triangles = new ArrayList<>();
		int index = 0;
		for (int i = 0; i < sides.length - 2; i++) {
			int[] tri = new int[3];

			for (int j = 0; j < 3; j++) {
				if (index < sides.length) {

					if (!discard[index]) {
						tri[j] = sides[index];
					} else {
						j--;
					}
					if (j == 1)
						discard[index] = true;
					if (j != 2)
						index++;

				} else {
					index = 0;
					j--;
				}
			}
			triangles.add(tri);
		}

		int[][] trianglesArray = new int[triangles.size()][3];
		triangles.toArray(trianglesArray);
		return trianglesArray;
	}