# Parametric curves

This topic is 3375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi!! I need that an object follows a path, made up of several parametric curves (with t=0 at the beginning and t=1 at the end). The problem is that I want it to have a constant velocity independently of the length of these curves. In a first step I preprocess each curve and store the spatial length a certain t increment supposes for that curve. Then, at run-time, I adjust the increment of t so that the travelled distance is consistent with the velocity. But a second problem comes out when the parameter increment results in different travelled distances depending on the value of t. Now and then, at the extremes of the curve (t close to 0 or close to 1) the object moves slower than at the middle of it (t close to 0.5), using the same increment of t. For example, for inc_t = 0.1 (t) 0.0--0.1---0.2----0.3------0.4------------0.5------------0.6------0.7----0.8---0.9--1.0 I could segmentate the curve and store an array with pairs (t,spatialLength), similar as I did before. However, this is neither an elegant nor efficient solution and is still far from perfect. Do you know any other way, please? Thank you a lot

##### Share on other sites
Parametrization by arc length is actually a difficult task, even with simple curves. An exact solution is usually difficult of impossible to find and this problem is usually solved with numerical techniques or with tables. What type of spline are you using?

##### Share on other sites
Suppose your spline is defined parametrically as x(t) and y(t).

Then your distance traveled (arc length) is the integral (from start to end) of sqrt( (dx(t)/dt)2 + (dy(t)/dt)2 ) dt

If x(t) and y(t) are cubic (a common spline type), then their derivative is quadratic. Squaring the quadratic terms gives a quartic. You can then combine the (dx(t)/dt)2 + (dy(t)/dt)2 into a single quartic.

You now have length = integral (from start to end) of sqrt ( some quartic polynomial ).

You really just are interested in the speed, not the actual length travelled, so you then find the derivative of both sides:

velocity = sqrt ( some quartic polynomial )

And you can easily decide to specify a constant squared velocity, so then you have:

C = some quartic polynomial.

You can then combine C into your quartic, and still have a quartic. Then you have:

0 = some quartic

Which can be solved analytically in constant time. Check out This directory in my project and this file particularly. The work is based off of this link. Basically you can simplify a quartic in to a cubic, and a cubic into a quadratic, and a quadratic into a linear. And from all those simplifications easily arrive at roots.

Hmm, that doesn't seem to quite get you the answer you want. The t roots you get are the times at which your velocity is right. It doesn't help you move through the spline at constant velocity.

Maybe someone can take what I have here and expand on it in the right direction?

##### Share on other sites
Quote:
 Original post by NumsgilAnd you can easily decide to specify a constant squared velocity, so then you have:C = some quartic polynomial.You can then combine C into your quartic, and still have a quartic. Then you have:0 = some quarticWhich can be solved analytically in constant time.Hmm, that doesn't seem to quite get you the answer you want. The t roots you get are the times at which your velocity is right. It doesn't help you move through the spline at constant velocity.Maybe someone can take what I have here and expand on it in the right direction?

As you noticed, setting the quartic polynomial to a constant just tells you the time (or times) at which the speed is C, but certainly the speed is not always this constant. apatriarca said it right about "reparametrization by arc length". The numerical method requires inverting an integral by arc length. See Moving Along a Curve with Specified Speed for details. My Curve2 and Curve3 classes have implementations, including ones for a curve made up of several parametric curves.

##### Share on other sites
That document is exactly what I needed :) Thank you all!

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632936
• Total Posts
3009312
• ### Who's Online (See full list)

There are no registered users currently online

×