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

Rotating a vector

  1. Jul 20, 2009 #1
    Lets say I have a velocity vector thats going to the east and I want it's direction to change to somewhere else like west, how would I be able to do that?

    What would be the maths required for this? The velocity vector already have a length and a direction.
     
  2. jcsd
  3. Jul 20, 2009 #2
    You'd use a rotation matrix which is an example of a change of basis. The type of math is linear algebra
     
  4. Jul 20, 2009 #3
    assuming you're working 2D (no up or down) the matrix to rotate a vector by theta is [itex]\begin{bmatrix}
    \cos \theta & \sin \theta \\[3pt]
    -\sin \theta & \cos \theta \\
    \end{bmatrix}[/itex]
     
  5. Jul 20, 2009 #4
    I searched wikipedia but it was too confusing so i asked for help here.

    EDIT: what about 3D?
     
  6. Jul 20, 2009 #5
    3D's a little more complicated since rotations do not commute. For example, if you think of an airplane it can do 3 things it can pitch, roll and yaw http://www.ultimatepointer.com/images/YawPitchRoll.jpg [Broken] Now the thing is that order matters. If you were to roll 90 degrees and then yaw 90 degrees your plane would not be in the same orientation then if you were to yaw 90 degrees then pitch 90 degrees. This means there's no one matrix to rotate any vector to any vector you instead have to think about the orientation and apply multiple in sequence, in the correct sequence (like pitch,roll,yaw). This should help http://en.wikipedia.org/wiki/Rotational_matrix if you haven't found it yet.
     
    Last edited by a moderator: May 4, 2017
  7. Jul 20, 2009 #6
    For 2D I still don't really get you, do I multiply it by cos angle and sin angle or the one below?

    Or do I subtract it.
     
  8. Jul 20, 2009 #7
    Have you never covered matrix multiplication?

    [itex]\begin{bmatrix}
    \cos \theta & \sin \theta \\[3pt]
    -\sin \theta & \cos \theta \\
    \end{bmatrix}\begin{bmatrix}
    x \\[3pt]
    y\\
    \end{bmatrix}=\begin{bmatrix}
    \cos\theta x + \sin \theta y \\[3pt]
    -\sin \theta x + \cos \theta y\\
    \end{bmatrix}[/itex]

    so you get the new x is [itex]\cos\theta x + \sin \theta y[/itex] and the new y is [itex]-\sin \theta x + \cos \theta y[/itex]
     
  9. Jul 20, 2009 #8
    In general for 2x2 matrices:

    [itex]\begin{bmatrix}
    a& b\\[3pt]
    c & d \\
    \end{bmatrix}\begin{bmatrix}
    x \\[3pt]
    y\\
    \end{bmatrix}=\begin{bmatrix}
    a x + b y \\[3pt]
    c x + d y\\
    \end{bmatrix}[/itex]
     
  10. Jul 20, 2009 #9

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    For rotations in 3 dimensions, you need to state an axis of rotation as well as an angle. That's why they are so much complicated.
     
  11. Jul 20, 2009 #10
    Is it taken in radians or degrees currently?

    Here's how I tried to apply it

    vx = Cos(angle)*vx+ Sin(angle)*vy
    vy = -Sin(angle)*vx+Cos(angle)*vy

    vx = velocity X
    vy = velocity Y
    angle = new angle
     
  12. Jul 20, 2009 #11

    Born2bwire

    User Avatar
    Science Advisor
    Gold Member

    Doesn't matter, the cosine of 90 degrees is the same as the cosine of 0.5*\pi. One note, the angle \theta is not the "new" angle, it is the angle of rotation.
     
  13. Jul 20, 2009 #12
    Ok a slighty offtopic question, is rotating a vector the same as changing the direction of a vector? How would you change the direction of a vector?

    vx = vx *Cos(angle)
    vy = vy *Sin(angle)

    or am I wrong?
     
  14. Jul 20, 2009 #13

    Born2bwire

    User Avatar
    Science Advisor
    Gold Member

    This formula does not preserve the vector's magnitude.
     
  15. Jul 20, 2009 #14
    Where can I find it? I googled to no avail too.
     
  16. Jul 20, 2009 #15

    Born2bwire

    User Avatar
    Science Advisor
    Gold Member

    maverick already gave you the rotation matrix for a 2D Cartesian coordinate system. If you want to rotate a vector, you use the appropriate rotation matrix. If you want to make a vector point in a desired absolute direction then you simply make a unit vector that points in the desired direction and scale it to the desired length.
     
  17. Jul 20, 2009 #16
    I tried that but it didn't work that's why I asked about the direction.

    vx = Cos(angle)*vx+ Sin(angle)*vy
    vy = -Sin(angle)*vx+Cos(angle)*vy

    I did something like this.

    Imagine actual angle is the front of the person but after setting the values, I set it to be 90 degrees that will be converted to radians but it bugs as the example shown above.

    The angle of the ball thrown is always different from any position.
     
  18. Jul 20, 2009 #17

    Born2bwire

    User Avatar
    Science Advisor
    Gold Member

    What example? If it's 90 degrees then the rotation is straightforward:

    v_x = v_y;
    v_y = -v_x;

    If our vector is (0,1), we can see that we easily get the correct vector of (1,0). Note that maverick's rotation matrix is a clockwise rotation with respect to the traditional x-y plane orientation.
     
  19. Jul 20, 2009 #18
    I solved it, thanks guys.
     
  20. Oct 17, 2009 #19
    Hi am new to this forum, i am working on spherical modal analysis. I need some help in rotation . One of the step in my analysis is to align the axis of reference of the field waves of the radiator to the axis of the dielectric lens. How should i proceed and do i have to use rotation matrix? Is rotation matrix different from wigner rotation matrix? Which matrix should i employ ?

    If my question is absurd pls ask me so that i can put my question clearly...........
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Rotating a vector
  1. Vectors or not? (Replies: 3)

Loading...