Jump to content
  • Advertisement
Sign in to follow this  
Jiia

Distance between directions [solved]

This topic is 5402 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 starting to frequent here. That's a bad sign [smile] I have a character who has a direction vector for his direction moving. And he has another direction vector that he wants to move. His desired direction to move may be way off from his current, and it may take many frames (time) to end up moving that way. Note that his movement direction has nothing to do with his facing direction. The only way I'm sure I can do this is to interpolate between the vectors (directions). The only way I'm sure I can do that is to have the total distance between them. I need the distance to set the interpolation factor to emulate direction-changing velocity. Or in other words, I want him to change to close directions in less time than a far directions. He will always change at a constant rate. Is interpolation a bad idea? Can I do this an easier way? If not, can anyone help me figure out how to get the angle distance between two direction vectors? I would really like the distance to be a factor (0.0 to 1.0), where 1.0 would be a 180 with any axis. But radians are just as good [smile] Thanks much for any help EDIT: Mixed up lingo [Edited by - Jiia on October 5, 2004 12:00:35 AM]

Share this post


Link to post
Share on other sites
Advertisement
My math skills are not the best out there. Let me see if I understand this. If the direction is completely the opposite, the dot product will be -1.0? If they are identical, the dot product is 1.0? Or did I get totally lossed? The math notations always throw me off.

EDIT: Bah, spelling

Share this post


Link to post
Share on other sites
correct, as long as both vectors are unit vectors. otherwise you'd do something like:

norm_dot = dot_product / (v1.length() * v2.length());

to bring them back in the range of -1 to 1

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!