The goal is to create an animation curve mathematically that moves like a sin curve but holds at the extremes. I would also love to be able to parameterize it.
In the graph note how the domain spent at either 1 or -1 increases while the function still transitions smoothly in and out of these extremes.
Thus far I have graphs of the following forms with no luck
sin(x)*sin(x)^a
sin(x)^a // This sort of works when a is [0, 1] however I do not like that the derivative appears infinite when y =0
sin(sin(x))
sin(x)+sin(x+a)
I really have not seen a formula that can do this. Is it even possible to translate a regular sine curve into one that lingers at its extremes?
A function that is not even technically sinusoidal would be ok so long as it is periodic or can be made periodic by modulo-ing x.
Try:
$$f(x) = \frac{\vert\sin x\vert^{2-p}}{\sin x}$$
If $p=0$, you have a regular sine curve:
When $p$ goes from $0$ to $1$, the function smoothly goes between the extremes. $p = \frac{1}{2}$:
Finally, as $p$ goes to $1$ you get the square wave.
The function can also be written as:
$$f(x) = \text{sgn}(\sin x)\cdot\vert\sin x\vert^{1-p}$$
This might give some more intuition as to why it works. For more, see Desmos.