Long story short I'm basing a keyboard animation on the sin-wave, $f = \sin(x)$ where x is time and $f$ is the height of a given key on the keyboard.
With this model, at $x = \pi/2$ we reach a peak height of the key, and at $x = 3\pi/2$ we have the key at its lowest point. Hopefully this makes sense.
Clearly modeling the movement after the sine wave implies that the key is constantly moving. I would like my key to instead stay at it's highest point for sometime, say $\pi$ seconds then press down and come back up like the original sin-wave,returning to its highest position in $2\pi$ seconds but then stay at its highest point again for $\pi$ seconds before repeating.
I made a terrible drawing to show what I mean: desired curve for key movement
Is there a way to write out this function without making a piecewise function? I know this is an odd question but I am just having fun with some of the trig functions I can use to animate. In case you're wondering I am using Cinema4D.
Welcome to math.se! Are you familiar with the min and max functions?
I would suggest using something like the following: $$f(x)=\min\left(\pi\sin5\left(x-\frac{\pi}{6}\right)+\frac{\pi}{2},\frac{\pi}{2}\right)$$ , which takes in some kind of sine curve and a line at $y=\frac{\pi}{2}$ (where you want the plateau to be) and plots the lowest value out of the two. So, the line will only show when the sine curve is sufficiently close to peaking.
It looks like this:
You can now manipulate it in whatever ways you choose! Hope this helps!