Thread: OpenGL Maths - Angle between 2 Vectors

1. OpenGL Maths - Angle between 2 Vectors

Hi,
I want the camera to have a 360 degree view, if i take a constant facing north and then a second value of where the player is looking, calculating the angle between the two for moving in the correct direction.
I am using gluLookAt, that is why i need to do it this way, i would be most grateful for any help. Thanks

Paul

2. Re: OpenGL Maths - Angle between 2 Vectors

Are you asking for the formula for the angle between two vectors?

gav

3. Re: OpenGL Maths - Angle between 2 Vectors

Since v1 dot v2 = |v1|*|v2|cos(theta)

you can solve for theta with

theta = acos((v1 dot v2)/(|v1|*|v2|))

P.S. |v| is the magnitude of a vector and dot refers to the dot product.

4. Re: OpenGL Maths - Angle between 2 Vectors

Hi,
Thanks, it was the formula for calculating the angle between two vectors that i was looking for. Thnaks again.

Paul

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•