问题
When calling the derivative method on the CatmullRomSpline, what exactly does this value represent? It’s been a while since calculus, but if my memory serves me correctly taking the derivative of the position with respect to time gives you the velocity at that point in time. But with CatmullRomSpline the “time” value is a percentage, so is the resulting derivative in pixels/percent?
I printed out the derivative values (vector length) along my path and the values go as high as “989.6049”, which doesn’t really make sense to me as the total length of the path is 2039 (calculated using the “approxLength(1000)” method). I’ve tried a few things to get the derivative values into a range that makes sense (like dividing by total path length) but I’m still not making sense of it.
Essentially, I’m trying to figure out how to get a constant velocity along the path. My plan is to use the derivatives to get the rate at a given instant and compare that to what the rate should be if it was constant (calculated from the length of the path) and then adjust the percent value that is fed into the CatmullRomSpline valueAt() method so that the resulting speed will be constant throughout the path. Thanks.
来源:https://stackoverflow.com/questions/32642338/libgdx-catmullromspline-derivative-meaning