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!

Vector rotation

  1. Apr 2, 2005 #1
    Hi! I'm trying to implement a FPS-camera. I need to calculate a new vector from another one, rotated a.

    This is of cource in 2D. Is this correct:
    x' = x * ||v|| sin a / y
    y' = - y ||v|| cos a / x
     
  2. jcsd
  3. Apr 2, 2005 #2
    if you want to rotate a vector (x, y) of an angle a to get a vector (x', y') you just need this:

    x' = x*cos(a) - y*sin(a)
    y' = x*sin(a) + y*cos(a)
     
  4. Apr 2, 2005 #3
    Ahh! Exactly what I was looking for.

    EDIT: Hello there! I found that my copy of Core Algorithms in Game Programming has a matrix for my 3D rotation.
     
    Last edited: Apr 2, 2005
  5. Apr 2, 2005 #4
    Consider two vectors which lenght is the same (rotation doesn't change the lenght, I think) and build two similar trinagles by add two lines from thier heads to the x-axes. Name them v=(x, y) and u=(a,b). Then obiously x/a =y/b. x=ay/b=a*||v|| sin(Pi - a)/b = x=a * ||v|| sin a /b In a similar way one can derive the other equation. Where is my error?
     
  6. Apr 2, 2005 #5

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    Sin(pi- a)? But a isn't an angle, it is a length. Where did you get this?
     
  7. Apr 2, 2005 #6
    I don't understand your description. A diagram would be helpful.
     
  8. Apr 2, 2005 #7
    Woops! It should be the angle between the vectors. Call it alpha istead. My own diagram tricked me.

    EDIT: When I think about it. Shouldn't it be (Pi-alpha)/2. :blushing: Oops.
    EDIT2: Can you even assume they're equal? I think I've made a complete fool of myself.
     

    Attached Files:

    Last edited: Apr 2, 2005
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Vector rotation
  1. Vector rotation (Replies: 1)

Loading...