import torch


def scale_bounding_box_diameter(bbox, scale):
    """
    Scale the diagonal of the bounding box bbox while maintaining its center position
    :param bbox: A bounding box represented as a pair (origin, size)
    :param scale: A scale factor by which to scale the input bounding box's diagonal
    :return: The (possibly scaled) axis-aligned bounding box for a point cloud represented as a pair (origin, size)
    """
    bb_min, bb_size = bbox
    bb_diameter = torch.norm(bb_size)
    bb_unit_dir = bb_size / bb_diameter
    scaled_bb_size = bb_size * scale
    scaled_bb_diameter = torch.norm(scaled_bb_size)
    scaled_bb_min = bb_min - 0.5 * (scaled_bb_diameter - bb_diameter) * bb_unit_dir
    return scaled_bb_min, scaled_bb_size