import math
import random


def random_position_in_arena(
    height_limits=(0.05, 0.15),
    angle_limits=(-2 * math.pi, 2 * math.pi),
    radius_limits=(0.0, 0.15),
):
    """
        Set a new position in the arena for the interaction object, which
        the finger has to reach.

        Args:
            height_limits: the height range to sample from, or
                a fixed height
            angle_limits: the range of angles to sample from
            radius_limits: distance range from the centre of the
                arena at which a sampled point can lie

        Returns:
            The random position of the target set in the arena.
        """
    angle = random.uniform(*angle_limits)
    radial_distance = random.uniform(*radius_limits)

    if isinstance(height_limits, (int, float)):
        height_z = height_limits
    else:
        height_z = random.uniform(*height_limits)

    object_position = [
        radial_distance * math.cos(angle),
        radial_distance * math.sin(angle),
        height_z,
    ]

    return object_position