Jump to content
  • Advertisement
Sign in to follow this  
Kevn

Rotating an object along a curve

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

Hey, I have an object that follows a Bezier Curve(in 2D), however I need it to rotate with the tangent of the curve as it follows. Currently I am taking the derivative of the Bezier Curve with respect to a time variable u, and taking the x and y coordinates at that u derivative location to use in my rotation matrix. My matrix looks like this:

 

| x/r  -y/r  0  0  |

| y/r   x/r  0  0  |

|  0     0   1  0  |

|  0     0   0  1  |

 

where the x and y values are the ones I took from the position at the derivative with respect to u and r = sqrt(x^2 + y^2).

Then I multiply this matrix to the object matrix.

 

Am I going about this correctly? If so, i'm probably messing up on my derivative. If not, what should be I doing?

Share this post


Link to post
Share on other sites
Advertisement
The matrix seems reasonable to me. Perhaps the derivative is wrong.

You could just approximate the derivative at the point by picking another point slightly further up the curve, take the difference, and use that for your x and y values in that matrix the same way. Perhaps this is what you're already trying? Edited by Nypyren

Share this post


Link to post
Share on other sites

I wasn't doing it that way, but I will definitely give it a try. That way I can fall back to it if I can't figure out the derivative. Thank you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!