Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Making Vector Addition programmeable

  1. Feb 3, 2004 #1
    Hello...I really want to make a program that can do vector addition and subtraction, given two or more vectors. The problem is, I'm not sure of the math that would be needed to do it. See, I want the person to be able to enter two or more vectors with a magnitude (length) and angle (with 0 degrees being 'up' and 90 degrees being 'right'). I'm struggling a bit with the actual math that needs to be done. I can do it on paper jsut fine, because the process of taking a bearing of 1125 degrees and making it 45, etc, things of this nature - is logical. But programs don't understand logic. That's where I hit the roadblock.

    I don't think you need to know any programming whatsoever to answer this (granted you know the answer)...just be able to say things like:

    1. Sbtract angle a from angle b, save to variable a.

    etcetera. I'd a little fuzzy on the part of figuring out how to "get two vectors together" to be prepared to use the law of cosines and whatnot to figure the resultant out. Can you help?
  2. jcsd
  3. Feb 3, 2004 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Convert each of the vectors to components in some basis, then add the components.

    - Warren
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook