Jump to content
• Advertisement

#### Archived

This topic is now archived and is closed to further replies.

# Bezier curve for motion prob

This topic is 5282 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

I can draw and move objects along a bezier curve but the problem I''m having is that at curves the motion slows down and at straight parts it speed up. My curve is notated by b(u), where u is apparently the percentage along the curve. How can I replace u with t being time instead so that the speed is constand all along the curve? Thanx!

#### Share this post

##### Share on other sites
Advertisement
the short answer is that you can''t =)

your best bet is probably to determine how far you want to move each frame... then go along your bezier curve by small steps until the distance you wanted to move is reached... or something like that, but you won''t be able to find the position in one step, you''ll have to do some kind of iterations...

#### Share this post

##### Share on other sites
You need to reparameterize the curve to produce a sequence u values that result in constant motion. The basic algorithm is to create a table of u values and the corresponding distance along the curve that the u value will calculate to. The arc length can be a little tricky to compute, but i''m sure google can walk you through some of them. After you have this table filled in, go through the arc length entries, find evenly spaced values, and use the corresponding u values for animation instead of just incrementing u at a constant rate. All this can be done during some initialization routine so performance should be unaffected at runtime. Hopefully, that makes some sense, i didn''t explain it very well.

#### Share this post

##### Share on other sites
Is this how all games create smooth curved motion or is there a better way of doing it, perhaps another type of curve will do what I need?
I found a link which seems to be related to what I described:
http://gamedev.net/community/forums/topic.asp?topic_id=99623

[edited by - dmatter on April 4, 2004 1:37:13 AM]

#### Share this post

##### Share on other sites
I guess you could try cubic spline interpolation, but I don''t know offhand if it''s any easier to get constant-rate motion that way :/

#### Share this post

##### Share on other sites
You can calculate the length of a curve f(x) like this:

L = the integral from a till b of sqrt(1+(f''(x))²)

You know a (the starting position). You can seek b so that L is constant.

(I don''t know bezier curves, but this should work for all kinds of curves)

#### Share this post

##### Share on other sites
erm, could you explain that a little more, I dont understand where that came from at all. Although it does seem familier I think I may have seen it somewhere before on this site (but can find it now - typical)

As far as I know there isnt an exact answer (like circumference of a circle) but I supose theres a formula, or something, that can approximate.

#### Share this post

##### Share on other sites
quote:
Original post by Koroljov
You can calculate the length of a curve f(x) like this:

L = the integral from a till b of sqrt(1+(f'(x))²)

You know a (the starting position). You can seek b so that L is constant.

(I don't know bezier curves, but this should work for all kinds of curves)

i see how this works... but it won't work for bezier curves... since bezier curves are parametric equations, they look something like this:

x = f(t)
y = f(t)
z = f(t)

and integrating sqrt(1+(f'(x))²) is pretty hard i think, i can't think of a way to do it off the top of my head even for the simple case of say f'(x) = x...

[edited by - SpaceDude on April 4, 2004 9:31:25 AM]

#### Share this post

##### Share on other sites
If you have a vector valued function
(f(t), g(t), h(t))
and you want each change in t to represent the same distance along the curve for the same change in t then you need find the arc length parametrization.
s = integral from L0 to L of sqrt((df/dt)^2+(dg/dt)^2+(dh/dt)^2))dt
L0 is a constant.
solve for L.
then your new curve is (f(L), g(L), h(L)) but replace L with what L is though.

[edited by - O_o on April 4, 2004 1:32:01 PM]

#### Share this post

##### Share on other sites
http://www.saccade.com/writing/graphics/RE-PARAM.PDF

[edited by - O_o on April 4, 2004 1:45:18 PM]

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
17
5. 5
• Advertisement

• 9
• 12
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632594
• Total Posts
3007260

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!