Calculating a Rotated Vector in 2D with FPS Camera

  • Context: Undergrad 
  • Thread starter Thread starter danne89
  • Start date Start date
  • Tags Tags
    2d Camera Fps Vector
Click For Summary

Discussion Overview

The discussion revolves around calculating a rotated vector in 2D space, particularly in the context of implementing a first-person shooter (FPS) camera. Participants explore various mathematical approaches to vector rotation and clarify concepts related to angles and lengths.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant proposes a method for calculating a rotated vector using the equations x' = x * ||v|| sin a / y and y' = - y ||v|| cos a / x, but does not clarify the context of ||v||.
  • Another participant provides a standard formula for rotating a vector (x, y) by an angle a, stating x' = x*cos(a) - y*sin(a) and y' = x*sin(a) + y*cos(a).
  • A later reply expresses satisfaction with the provided formula and mentions finding a relevant matrix for 3D rotation in a reference book.
  • One participant attempts to derive relationships between two vectors of equal length using geometric reasoning but questions their own understanding and the validity of their approach.
  • Another participant challenges the use of "sin(pi - a)" in the context of the discussion, pointing out that 'a' is not an angle but a length, leading to confusion about the terms used.
  • Subsequent posts reflect uncertainty about the correctness of earlier statements, with one participant admitting to a mistake in terminology and questioning the assumptions made about the vectors.

Areas of Agreement / Disagreement

Participants express differing views on the correct approach to vector rotation, with some agreeing on the standard formula while others present alternative methods. The discussion remains unresolved regarding the validity of the initial proposed equations and the assumptions made about the vectors.

Contextual Notes

There are limitations in the clarity of terms used, particularly regarding the distinction between angles and lengths. The derivation attempts rely on geometric reasoning that may not be fully justified, and assumptions about vector equality are questioned.

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:

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 24 ·
Replies
24
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
1
Views
2K