Sign in to follow this  

motion evenly spaced on a bezier curve

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys Here's my problem: i'm trying to move a string of balls on an irregular curved trajectory. My solution was to use quadratic Bezier curves. However, i run into a problem: i cant move with the same amount of space on the curve, because points are more far apart from each other if they are away from control points, and are closer to each other when the curve is close to its control points. For a simple example, let's say i have a Bezier curve that emulates a straight line, so 2 control points are close to one end and other 2 control points are close to the other. If i am stepping through the curve with a constant value, i get points very close to one another when i am close to each end of segments, and points distant from each other when i am in the middle of segment. This causes the movement to be irregular, which is unacceptable. Do you have any idea how to move constantly on a Bezier curve? Thanks Eugen

Share this post


Link to post
Share on other sites

Thanks, that has given me some clues. However, it looks like there are some math function that i don't have / know to implement: "Integral" and "derivative" being the first two. I am not very familiar with this field, and maybe there are some simple / common implementations out there that i could use. Maybe the is somewhere an example for this kind of implementation, or i am asking way too much :) ?

Share this post


Link to post
Share on other sites

Thanks, that has given me some clues. However, it looks like there are some math function that i don't have / know to implement: "Integral" and "derivative" being the first two. Also, i dont know how to find the total length of a bezier curve, a required parameter in this algo.
I am not very familiar with this field, and maybe there are some simple / common implementations out there that i could use. Maybe the is somewhere an example for this kind of implementation, or i am asking way too much :) ?

Share this post


Link to post
Share on other sites
If you don't want or can't express the arc length of the curve in a closed form, then you can simply break the path up into tiny pieces and make a table that maps from linear space to parameter space. Then you can simply use the table to interpolate the position at the desired speed. Of course, this can eat up a fair chunk of memory depending upon how long and complex the curve is.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mastaba
If you don't want or can't express the velocity of the particle along the curve in a closed form, then you can simply break the path up into tiny pieces and make a table that maps from linear space to parameter space. Then you can simply use the table to interpolate the position at the desired speed.


Yea, that was my last option, i was hoping for something 'smarter' :). I need to move a distance on each frame. Sometimes i need to make collision tests, and then i need to move step by step, but most of the time i need to move with a distance on the curve. If i make a table with value for each small step on the curve, i still need to move step by step :). It would be a little more efficient, though.

Share this post


Link to post
Share on other sites
Quote:
Original post by EugenB

Thanks, that has given me some clues. However, it looks like there are some math function that i don't have / know to implement: "Integral" and "derivative" being the first two. I am not very familiar with this field, and maybe there are some simple / common implementations out there that i could use. Maybe the is somewhere an example for this kind of implementation, or i am asking way too much :) ?


I have an implementation of this in my Curve2 and Curve3 classes at my website.

Share this post


Link to post
Share on other sites

I have found another idea, which is apparently simpler: i create a look-up table scanning the curve with a small step, and keeping for each step the distance computed from start of curve. So i will have a table with pairs of (t, dist). At runtime, i take for current 't' its distance and add distance i want to move. However, finding the closest "t" for this distance means scanning the table step by step until i found a distance greater than mine, and then i interpolate betweend found position and previous step.

I was wondering is there any faster way to find the desired "t" from known "distance", knowing that the table is ordered?

I guess its a kind of 'insertion' into an ordered list? Maybe a binary search?

Share this post


Link to post
Share on other sites
Quote:
Original post by EugenB

I have found another idea, which is apparently simpler: i create a look-up table scanning the curve with a small step, and keeping for each step the distance computed from start of curve. So i will have a table with pairs of (t, dist). At runtime, i take for current 't' its distance and add distance i want to move. However, finding the closest "t" for this distance means scanning the table step by step until i found a distance greater than mine, and then i interpolate betweend found position and previous step.

I was wondering is there any faster way to find the desired "t" from known "distance", knowing that the table is ordered?

I guess its a kind of 'insertion' into an ordered list? Maybe a binary search?


I came across the same kind of problem; I wanted to parameterise my curves with distance along the curve as the parameter. I learned a lot from reading Dave Eberly's stuff (thanks Dave). I need to go a little beyond reparameterising a curve, because I want to reparameterise a surface so that there cannot be any zero-length normal vectors.

For numerical integration and differentiation, there is the GNU Scientific Library (GSL). Try Googling it. It has various kinds of numerical differentiation and integration, which are probably not terribly fast but should be OK for getting something working.

I think that the technique you're suggesting may well work, but might have poor accuracy for certain cases of Bezier curve; for example when the tangent vector at one end is very much bigger than the tangent vector at the other end. To compensate for that you may find yourself having to use a very small stepsize, which may end up being computationally less efficient in the long run.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this