def centroid(vertices):
    """
    Compute the centroid of a triangle (center of gravity).

    :param vertices: The triangle vertices (3 by n matrix with the vertices as rows (where n is the dimension of the
        space)).
    :returns: The triangle centroid.
    :rtype: n-dimensional vector
    """
    return (vertices[0] + vertices[1] + vertices[2]) / 3