0

I have been investigating Catmull-Rom (CR) splines for interpolating curves and like my results so far, though I am having a fatal issue: Essentially, I am unable to map the "t" (say 0<=t<=1 where it measures the... for lack of a better way to explain it... 'parameterized' horizontal distance from P1 to P2 (using the P0,P1,P2,P3) notation here) to a tangible "x" value that would actually be charted in an X,Y coordinate space. Of course this is mostly a problem when using non-uniform CR splines (because xi=(ti-t0)+x0 in that case). I specifically like the features of the centripedal (alpha=0.5) CR splines, but the best I can do right now is ask my function to give me back a load of points and draw the curve. I am unable to say for example "Give me the point on the curve when x=some point i want. I have been able to recreate CR splines in excel and python, but still having no luck with the t->x mapping and my ultimate goal, asking to interp a specific x point and returning the corresponding y-value.

https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline is a good summary of what I have (the python code there is close to mine as well)

Vlox
  • 717
  • 8
  • 18
  • You want to get y as y=f(x) from y=g(t) and x=h(t) basically using y=g(h'(x)). Similar problem here: (http://stackoverflow.com/questions/11518054/transform-2d-spline-function-ft-into-fx). Might also ask over at http://math.stackexchange.com – Mikegrann Aug 25 '16 at 16:18
  • yes exactly, looking basically to get f(x) instead of f(t), but for the non-uniform catmull-rom splines. I checked that first link and basically looks like returning a lot of points and linearly interpolating those is an easy work-around (which I've already done), but it's less than ideal. Ultimately I'm trying build a python and vba function to use in my models that would be "=CatmullRom(Xs,Ys,alpha,interp_point)". I will continue to search math.stackexchange and maybe post there as well. – Vlox Aug 25 '16 at 16:27
  • check the second answer in the linked question. Instead of approximating, you could figure out the roots of the cubic equation x=f(t), which is a relatively simple problem. Then when you have solutions for t, you can check them for validity and plug the right one in for your value of y. (Involves taking some roots, which is computationally heavy, so approximating could still be your best bet for large datasets). – Mikegrann Aug 25 '16 at 17:38
  • I'm still not sure how the "exact" method works as mentioned in another thread I found today: http://stackoverflow.com/questions/1515828/getting-the-point-of-a-catmull-rom-spline-after-a-certain-distance?rq=1 and no one has actually provided it. Also, still unsure of how to implement the Root finding method, and where/why that becomes more computationally expensive then basically saying "return me N points on the segment for evenly spaced, small intervals of 't' and I will interpolate to the X I want", which seems to be the prevailing method still. Although I am curious on how the other's work – Vlox Aug 26 '16 at 13:33

0 Answers0