import math


def clamp(length, height):
    """
    Takes in position (length) of the stage
    and height between impact point on mirror
    and detector. Outputs position with boundary
    restraints.
    """
    upper_boundary = 250 + height / math.tan(math.radians(72))
    lower_boundary = 250 + height / math.tan(math.radians(108))
    return math.trunc(max(min(length, upper_boundary), lower_boundary))