# Need help modeling a waveform

I’m making a biped and trying to come up with some control function to model the angle that each servo should be at. What I’ve come up with for the hip is that I need a function comprised of two sinusoids. When the function is increasing, I need it to increase at a rate ‘r’, so something like sin(rt), and when it’s decreasing I need it do decrease at a rate of 1/r so something like sin((1/r)t).

I’m able to come up with each part individually, however combining them is clearly a completely different ballgame because they do not share the same period. I’ve read some things about using a Fourier transform, but I’m not sure and I don’t know much about it. Can someone help me out?

By the way, here is the partial function that I was able to come up with (however it may be meaningless in terms of the entire function). This is for the part when the function is increasing, and I was assuming the format of the function to be as such:
sin(rt)*L1 + sin(1/rt)*L2, where L1 and L2 are limiting factors such that L1 equals 0 when the function is decreasing and 1 when the function is increasing. And vice versa for L2. So, here is sin(rt)*L1 assuming r to be 3. Plug it into wolfram alpha to see it in action:

plot sin(3t)abs(abs(cos(3t) + .0001)+cos(3t) + .0001)/(2cos(3t) + .0001)

Just a quick preview of the graph you mentioned ( for those who don't have wolfram installed :) ) Although, I'm struggling to figure out what you really want to do :/ but I hope that the graph can inspire others :)

Thanks so much for graphing it! Here is a better and shorter description. I would like a periodic function, let's just say with a constant period of 2*pi, that when the slope is positive, to have a slope of 'r', and when the slope is negative, to have a slope of 1/r.

This means that if the period is 2*pi, instead of the midpoint between the peak and trough of one period being located at pi, it is located at some value smaller than pi.

So when integrating those slope's, we would get the functions that have a slope with r or 1/r. This gives us the r²/2 function with a slope of r. The function that has a slope with 1/r would be ln(r) So now we would need to make a periodic function that "pastes" these two functions after each other. Wouldn't it be possible that - in your program- you check in which of the two cases you are (0..pi or pi..2pi) and then use the corresponding graph? Having the blue graph moved with Pi on the 'x axis' would mean that we have to take the ln(r - Pi) instead of just ln(r)

I was kind of hoping to figure out a cool, elegant solution, but yeah I can just write that in my program haha. Thanks