def _compute_tagged_plane_mask(self, obj, face_mask, plane, tolerance):
        """
        Given a plane, return a mask of all polygons in obj that are coplanar with the plane.
        """
        plane_mask = np.zeros(len(obj.data.polygons), dtype=bool)
        ref_poly = self.planerep_to_poly(plane)
        ref_vertex = butil.global_vertex_coordinates(
            obj, obj.data.vertices[ref_poly.vertices[0]]
        )
        ref_normal = butil.global_polygon_normal(obj, ref_poly)

        for candidate_polygon in obj.data.polygons:
            if not face_mask[candidate_polygon.index]:
                continue

            candidate_vertex = butil.global_vertex_coordinates(
                obj, obj.data.vertices[candidate_polygon.vertices[0]]
            )
            candidate_normal = butil.global_polygon_normal(obj, candidate_polygon)
            diff_vec = ref_vertex - candidate_vertex
            if not np.isclose(np.linalg.norm(diff_vec), 0):
                diff_vec /= np.linalg.norm(diff_vec)

            ndot = np.dot(ref_normal, candidate_normal)
            pdot = np.dot(diff_vec, candidate_normal)

            in_plane = np.allclose(ndot, 1, atol=tolerance) and np.allclose(
                pdot, 0, atol=tolerance
            )

            plane_mask[candidate_polygon.index] = in_plane

        return plane_mask

        Given a plane, return a mask of all polygons in obj that are coplanar with the plane.
        
infinigen/core/constraints/example_solver/geometry/planes.py