So I'm working on a program that graphs a bezier curve by manipulating the control points. This curve represents the velocity of something over time; I also want the option manipulate it all in terms of acceleration in respect to that velocity. My initial thought was to take the derivative of the bezier curve function and plot that with the same control points.
In my program it works, however I think the math doesn't really do what I want. This nice article has helped me on the math so far, but the problem I'm facing is that the derivative curve is simply "off."
The graphs below are velocity on the Y axis and time on the X axis.
Here's what the graph looks like with my bezier function:
Now, the derivative of that looks like this...
I'm not sure if my math is off, or if that's simply what the derivative of the bezier function actually does. But, what I really want to do is take my bezier curve and draw the rate of change over the same domain. However, the derivative seems to take it out of the domain (when you see my graphs below you'll see how the derivative changes the scope).
What can I do to extrapolate the data I'm looking for from this curve (turning velocity over time with a bezier function into acceleration over time)?
Here's the code where I'm drawing the point of the graph (it is calculating the curve from 0 to 1 and drawing a point there). I subract an extra 1 with n (the number of control points) as I calculate in an extra 1 at some point in the code above to be more efficient elsewhere:
position $+=$ linearCombination$(n - 1, z) \cdot$ Mathf.Pow$((1.0f - t), n - 1 - z) \cdot$ Mathf.Pow$(t, z) \cdot$ controls[$z$].position;
position $+=$ linearCombination$( n - 2, z ) \cdot$ Mathf.Pow$(1.0f - t, n - 2 - z) \cdot$ Mathf.Pow $(t, z) \cdot (n - 1) \cdot$ (controls[$z + 1$].position - controls[$z$].position );