Jump to content
  • Advertisement
Sign in to follow this  
LostSource

Vector Math

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

[ Vector Addition ] Say I have three vectors A, B, C with the mag. and dir. discribed below:
vector |  mag   | dir (degrees)
---------------------------------
  A    |  5 cm  |  90
       |        |
  B    |  3 cm  |  210
       |        |
  C    |  4 cm  |  180
I'm wanting to add the three vectors A + B + C = R. How would I do this, it's confusing me some what (well actually alot). Because I know R != 12. * = vector head
          * 
         /|
      B / |
   C   /  | A
 *----*   |
          |

Share this post


Link to post
Share on other sites
Advertisement
Well, if you have the starting location and the end location you can use a simple "distance between two points" equation to figure length:

I believe it's L = (x2-x1)/(y2-y1)

Someone correct me if that's wrong. Hope it helps.

-AJ

Share this post


Link to post
Share on other sites
To find a vector from coordinates is easy. When you add the vectors using y=a*sin(dir) and x=a*cos(dir), you get a resultant x and y:
length=square_root(x^2+y^2);
dir=tan(y/x);


Annother way of doing this is writing a function that adds two vectors and returns the resultant. To add the three vectors, you could then do:
vector R=add(add(A,B),C);

To add two vectors, you can use the law of cosines and the law of sines.

Share this post


Link to post
Share on other sites
Folks, this question is presented in a way that strongly resembles a school or homework problem. Try to recognize this kind of clean, very theoretical problem statement, and in the future provide only advice or link to resources. Gamedev is not a homework site.

Read the Forum FAQ for more details, along with links to pages that are appropriate for school type problems.

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!