in h3_vertex.c [128:152]
int vertexNumForDirection(const H3Index origin, const Direction direction) {
int isPent = H3_EXPORT(isPentagon)(origin);
// Check for invalid directions
if (direction == CENTER_DIGIT || direction >= INVALID_DIGIT ||
(isPent && direction == K_AXES_DIGIT))
return INVALID_VERTEX_NUM;
// Determine the vertex rotations for this cell
int rotations;
H3Error err = vertexRotations(origin, &rotations);
if (err) {
return INVALID_VERTEX_NUM;
}
// Find the appropriate vertex, rotating CCW if necessary
if (isPent) {
return (directionToVertexNumPent[direction] + NUM_PENT_VERTS -
rotations) %
NUM_PENT_VERTS;
} else {
return (directionToVertexNumHex[direction] + NUM_HEX_VERTS -
rotations) %
NUM_HEX_VERTS;
}
}