Jump to content
  • Advertisement
Sign in to follow this  
NegativeZero

Rotation Problem

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

Okay, I'm working on implementing a small, simple demo, using C++ and OpenGL. Implementational specifics aside, I basically have an object which has its own orientation matrix and position. From this matrix I can quickly extract a forward, up and side vector. I have a goal point that I want to move this object towards. The object has a maximum turn rate. So, in essence, I have a heading vector and a goal vector (object position - goal position) and I want to rotate by max_turn_rate or the angle between these vectors, whichever is smaller. To do this currently, I'm taking the cross product of both vectors as a turn axis, and rotating by the angle between the vectors (or the max turn rate) which is calculated from the dot product. It all works fine for a little while, then the object will get to a point where it turns away. Obviously this is caused by the cross product going whacked. When the two vectors are close to parallel, the cross product becomes somewhat arbitrary, rotating about the two vectors and basically going crazy. I talked about this with a few people, and realised that I probably need to limit the amount that the turn axis (cross product) can change at each time step, as at the moment I'm allowing my object to only turn a small amount, but still letting it flip completely upside down in the space of a single frame. However I can think of no good way to implement this limitation. I'm certain that there's an easy solution to this, because I'm sure that I'm not the first person to have the problem. The actual behavior is fine until it gets into this situation, which would indicate that everything is being calculated correctly except in this special case. Also, I am re-orthoganilising the matrix at every timestep, so this is not a simple rounding error creeping in. Any help on this would be extremely appreciated. EDIT: Just realised I should have posted this in graphics programming, not game programming. Sorry.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Why do you calculate the axis over and over again? Isn't it fixed and you just rotate around it from an initial to the final orientation in multiple small steps (depending on the max turn rate?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!