3 comments

[ 3.6 ms ] story [ 12.8 ms ] thread
I'd probably prefer

0.5-0.5cos(pit/T)

to a function which has a nonzero derivative at the start at the end.

Hmm, that does work nicely. The major problem with it though is that I don't see an easy way to configure the steepness. I suppose you can force it to 0 and 1 before and after the first rise. Not a terrible solution, a bit less elegant though, but as you said it does have a nice zero velocity at the starts and ends.
Instead of

  cos(...) 
you could use

  pow( cos(...), a )
where a can be used to adjust the steepness.

I can't plot it right now and I think I'm missing something, but you get the general idea of using the power of a function which goes form 0 to 1 to adjust steepness.

Another solution would be a 2-piece function kind of

  0.5*pow( 2*t/T, a ) for t < T/2
and

  1-0.5*pow( 2*(1-t/T), a ) for t > T/2
which makes a similar slope as the cosine but is easier to calculate.