/**
 * Next vertex in the loop around the face
 * @param {TopoTriangle} face
 * @param {TopoVertex} vertex
 * @returns {TopoVertex}
 */
export function query_face_prev_vertex(face, vertex) {
    const vertices = face.vertices;
    const vertex_count = vertices.length;

    for (let i = 0; i < vertex_count; i++) {
        if (vertices[i] === vertex) {
            return vertices[(vertex_count + i - 1) % vertex_count];
        }
    }

    throw new Error('Vertex is not part of this face');
}
