Jump to content
  • Advertisement
Sign in to follow this  
luasitdown

How to judge two vector direction

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

given two vector that point the same direction or total opposition. How to know they the same or the opposition? use dot product ,cos(0)= cos(180);

Share this post


Link to post
Share on other sites
Advertisement
Use the dot product for 2 vectors. If they are going in the same general direction, the dot product should be positive, else the dot product should be negative.

Share this post


Link to post
Share on other sites
cos(0) = 1
cos(180) = -1

if you normalize the 2 vectors and then dot them, you will get 1 if they point exactly the same direction, or -1 if they point exactly the opposite direction.

Also, as Endar said, if they point in the same hemisphere, the value will be > 0, and if they point in opposite hemispheres, the value will be < 0.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!