Sign in to follow this  

Calculating rotation on a path animation

This topic is 3315 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'm sure this question has been asked a million times... I have an object, lets say its a ferrari. Now, i set up a path animation for this object to go to the points: (-5000, -5000, -10000), (-5000, 5, 5) (5000, 5, 5) So the ferrari animates to each of those points, but it appears to drift rather than point in the direction of motion. What is the best place for me to get started learning about this type of problem?

Share this post


Link to post
Share on other sites
This sounds like a job for trig and linear algebra.
You can use atan2 to calculate the angle of rotation between two points.

http://en.wikipedia.org/wiki/Atan2

Also you might consider defining an interpolating spline between the points so the ferrari doesn't just drive straight to one point, turn a sharp angle and drive to the next.

http://en.wikipedia.org/wiki/Spline_(mathematics)

Share this post


Link to post
Share on other sites
I would do the spline idea but use say the middle of the car as the point that is checking to see if it's on the spline. Also I would go ahead and project the front of the car(say right in between the front wheels) onto the spline also, that way it will always follow it and not appear to drift.

Recap:

Do a spline between those 3 points (wikipedia has a great article on splines).

Have the middle of the car (or possibly the rear 2 wheels) follow the spline.

Next using the distance from the first point to the front of the car find the point on the spline that is that same distance from the middle of the car. Set the front point = to that.

Share this post


Link to post
Share on other sites

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