1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Setting a vector to another magnitude

  1. Jul 19, 2009 #1
    When you set it, initially I have to do

    length = Sqrt(x*x+y*y*z*z)
    length = newlength/length
    set all the velocities to multiply by length

    I am wondering what is this for?

    length = newlength/length
  2. jcsd
  3. Jul 19, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    newlength/oldlength is the fraction by which the length has to increase. The length of the new vector will be
    || oldvector * newlength / oldlength || = || oldvector || * newlength / oldlength = oldlength * newlength / oldlenght.

    Alternatively, you can look at it this way: if you have a vector v, first divide it by its length to make a unit vector u (in the same direction but with length 1). Then multiply u by the length you want it to have to get the new vector:
    v' = u * newlength = (v / oldlength) * newlength = v * (newlength / oldlength)
    where oldlength is the length of v (sqrt(x^2 + y^2 + z^2)).
  4. Jul 19, 2009 #3
    Well, you're talking about a vector, so I assume direction is important. It would be easier to change leingths of individual cartesian components by the desired amount. In cylindrical and sphercal, you merely change r.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook