Calculating a Rotated Vector in 2D with FPS Camera

danne89
Messages
180
Reaction score
0
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
 
Mathematics news on Phys.org
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)
 
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:
Consider two vectors which length is the same (rotation doesn't change the lenght, I think) and build two similar trinagles by add two lines from their 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?
 
Sin(pi- a)? But a isn't an angle, it is a length. Where did you get this?
 
I don't understand your description. A diagram would be helpful.
 
HallsofIvy said:
Sin(pi- a)? But a isn't an angle, it is a length. Where did you get this?
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.
 

Attachments

Last edited:
Back
Top