Okay, this is more of a calculus question than a Javascript question, but since I'll be using the answer, when I find it, as part of an algorithm I'm implementing in a script, I hope it's okay to ask here. I've looked around online to no avail, and I can't find my old calculus textbooks so I'm rather up a creek at the moment.

The problem is thus: I have a function for position in one dimension as a function of time:

p(t) = yOffset + (deltaP/2) - (deltaP/2) * cos( pi*xOffset + ((pi*t)/deltaT))

which produces a smooth transition from initial position yOffset to final position yOffset + deltaP in time deltaT.

But, let's say somewhere over the course of that motion, I want to smoothly transition to a new position equation that reaches a different final point in a different elapsed time -- in my script, triggered by a user interrupting the standard animation by clicking on a button. I remember enough calc to know that I'll need to know the position, velocity, and acceleration (also know as p(t), p'(t), and p''(t) -- the equation and its' first and second derivatives) at the time when the transition occurs, and the new function will need to match all three values for that time. That's not too tricky, just a matter of solving equations.

The tricky bit is that I want to specify -two- points on the new equation -- the transition point, which will be somewhere along the curve, and the new endpoint. I totally don't remember enough math to get this right, and trial-and-error isn't getting me anywhere.

If anyone could offer suggestions or references, I'd appreciate it greatly.