in src/h3lib/lib/faceijk.c [609:661]
void _faceIjkPentToVerts(FaceIJK* fijk, int* res, FaceIJK* fijkVerts) {
// the vertexes of an origin-centered pentagon in a Class II resolution on a
// substrate grid with aperture sequence 33r. The aperture 3 gets us the
// vertices, and the 3r gets us back to Class II.
// vertices listed ccw from the i-axes
CoordIJK vertsCII[NUM_PENT_VERTS] = {
{2, 1, 0}, // 0
{1, 2, 0}, // 1
{0, 2, 1}, // 2
{0, 1, 2}, // 3
{1, 0, 2}, // 4
};
// the vertexes of an origin-centered pentagon in a Class III resolution on
// a substrate grid with aperture sequence 33r7r. The aperture 3 gets us the
// vertices, and the 3r7r gets us to Class II. vertices listed ccw from the
// i-axes
CoordIJK vertsCIII[NUM_PENT_VERTS] = {
{5, 4, 0}, // 0
{1, 5, 0}, // 1
{0, 5, 4}, // 2
{0, 1, 5}, // 3
{4, 0, 5}, // 4
};
// get the correct set of substrate vertices for this resolution
CoordIJK* verts;
if (isResClassIII(*res))
verts = vertsCIII;
else
verts = vertsCII;
// adjust the center point to be in an aperture 33r substrate grid
// these should be composed for speed
_downAp3(&fijk->coord);
_downAp3r(&fijk->coord);
// if res is Class III we need to add a cw aperture 7 to get to
// icosahedral Class II
if (isResClassIII(*res)) {
_downAp7r(&fijk->coord);
*res += 1;
}
// The center point is now in the same substrate grid as the origin
// cell vertices. Add the center point substate coordinates
// to each vertex to translate the vertices to that cell.
for (int v = 0; v < NUM_PENT_VERTS; v++) {
fijkVerts[v].face = fijk->face;
_ijkAdd(&fijk->coord, &verts[v], &fijkVerts[v].coord);
_ijkNormalize(&fijkVerts[v].coord);
}
}