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.

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 on other sites
Try this: Dot Product. Equations 1 and 7 are what you need.

Share on other sites
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 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 on other sites
Ahh, thanks much for the help!

• 18
• 20
• 12
• 21
• 16