import math


def calc_camera_angle(
    x_distance: float, mount_height: float, target_height: float, limelight
):
    """
    Calculate the camera's mounted angle from known properties. Set the robot to a fixed
    distance away from the target and pass in the other properties and it will calculate
    the angle to put into the calc_distance function

    Args:
        x_distance: The known distance away from the wall the target is on
        mount_height: The height that the camera is mounted off the floor
        target_height: The height the target is from the floor
        limelight: The limelight object to pull networktables values from

    Returns:
        Gives the angle (in degrees) that the camera is mounted at
    """
    a1 = -limelight.vertical_offset + math.degrees(
        math.atan((target_height - mount_height) / x_distance)
    )
    return a1