I am creating an implementation of a cubic hermite spline in Python. One feature I would like to add is a method to compute the slope (IE the derivative) for a given T value.
Currently, I can do it numerically with the following code:
dt = .00001 def derivative(t): dx = my_spline.get_value(t + dt) - my_spline.get_value(t) return dx/dt
I would like to do it analytically though - it seems like it should be possible.
Wikipedia defines four basis functions which are multiplied by constants - my first intuition was that I could simply take the derivative of each basis function and leave the constants the same, since they won't affect the derivatives. This doesn't work in practice, and it makes sense why: the first and third constants are based on position, and we don't want position data, we want the derivative of position.
And at this point I'm lost. I've taken a few guesses but none of them have given me the results I expected. How do I do this?