# Aim/Scope Oscillation Algorithm

I have been struggling to find an algorithm to implement something that will make a direction oscillate within a cone constraint, in a helix-shaped fashion as in photo (it will always go back to the centre after traveling toward the boundaries of the constraint, it doesn't have to hit the max amplitude everytime). Do you know any algorithm that does this?

EDIT: My mind is telling me that this is somehow similar to a gravity pull but I don't know how to ensure that it always goes back to the centre.

Using polar coordinates would do the trick. Here’s a graph of the function r=sin(2.3θ), with θ going from 0 to 2π:
Given r and θ, you can convert back to Cartesian (x/y) coordinates with x = r cos θ and y = r sin θ. Increase θ steadily over time, add the resulting x and y offsets to your aim direction, and you should have the effect you’re after.