def min_dist_2d(scene, a: Union[str, list[str]], b, visualize=False):
    """
    projects onto b and finds the min distance between a and b
    """
    if isinstance(a, str):
        a = [a]

    if visualize:
        fig, ax = plt.subplots()
    min_dist = np.inf

    b_path2d, to_3D = b.to_planar()
    plane_normal, plane_origin = iu.get_plane_from_3dmatrix(to_3D)

    a_meshes = iu.meshes_from_names(scene, a)

    a_projections = [
        trimesh.path.polygons.projected(mesh, plane_normal, plane_origin)
        for mesh in a_meshes
    ]
    # Measure the distance
    for a_proj in a_projections:
        source_geom = a_proj
        target_geom = b_path2d.polygons_closed[0].exterior
        dist = source_geom.distance(target_geom)
        if dist < min_dist:
            if visualize:
                pt_a, pt_b = nearest_points(source_geom, target_geom)
                ax.plot([pt_a.x, pt_b.x], [pt_a.y, pt_b.y], color="red")
                # plot source and target geoms
                iu.plot_geometry(ax, source_geom, "blue")
                iu.plot_geometry(ax, target_geom, "green")
            min_dist = dist

    if visualize:
        plt.show()
    return min_dist

    projects onto b and finds the min distance between a and b
    
infinigen/core/constraints/evaluator/node_impl/trimesh_geometry.py