Jump to content

Constant Speed over Catmull rom splines


beuleal
 Share

Recommended Posts

Hi guys,

 

Im working with catmull rom interpolation (like code tips 8), and i dont know how to set a constant speed to my sprite over the lines/ curves.

 

See this video[1]. At, ~1h56, the graph reorder the points and than the magic happends! The sprite goes with a constant speed over the catmull rom interpolation! 

 

How can i do that??

 

 

 

[1]https://youtu.be/YbwuzpsawcY?t=1m53s

Link to comment
Share on other sites

 Unfortunately, this is not easy. Look here: http://gamedev.stackexchange.com/questions/47354/catmull-rom-spline-constant-speed

 

 The approach taken there works like this: you are interpolating from 0 to 1 between two points on curve, so:

- set some small increment and calculate new point on the curve,

 -then calculate distance from previous point,

 - repeat this and accumulate total length of all steps until you reach speed your object should move.

 

 In fact: you are summing length of line segments that approximate curve. If chosen step is small than these segments are very close to original curve. Setting step too small means lot of calculations. So, depending on your implementation you can calculate this "off-line" and change your curve points into another set of points, where all arcs between them have same length.

Link to comment
Share on other sites

 Unfortunately, this is not easy. Look here: http://gamedev.stackexchange.com/questions/47354/catmull-rom-spline-constant-speed

 

 The approach taken there works like this: you are interpolating from 0 to 1 between two points on curve, so:

- set some small increment and calculate new point on the curve,

 -then calculate distance from previous point,

 - repeat this and accumulate total length of all steps until you reach speed your object should move.

 

 In fact: you are summing length of line segments that approximate curve. If chosen step is small than these segments are very close to original curve. Setting step too small means lot of calculations. So, depending on your implementation you can calculate this "off-line" and change your curve points into another set of points, where all arcs between them have same length.

Thanks Tom,

 

Until come to forum, i did a function that calculates how many dots has between the first and the next point, and tried to make this value a reference for the next line. It was hard, but solved a little bit. In the curve, it does not work as expected.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...