Skip to main content
gamedev.net
🔒 Locked

Getting angles

Started by Greg K Dec 20, 2002 at 1:42 AM 4 replies 350+ views
Original Post
Greg K
Greg K
I want two angles:
    |     
    |--\  
    |  |   This one (pitch)
    |__|_____
   /  /
  /--/ and this one (yaw)
 /
/
(Assume that a vector from the origin is going to (2,2,2))
[\code]

I was thinking of doing this:
pitch = atan2(z,x));
yaw = atan2(y,x));

Unfortunatly the pitch is wrong. The higher the yaw is, the more the pitch is wrong. I cannot find the relationship between them though. Any help?    
MattCarpenter
MattCarpenter
Use DotProduct maybe?
It returns the cosine angle of 2 vectors (whatever that means)

// Dot Product (a x b)
inline float vecDotProduct(vec3_t a , vec3_t b)
{
return ( a.x * b.x + a.y * b.y + a.z * b.z );
}


I think a and b must be normalized
//att
Basiror
Basiror
quote:
Original post by MattCarpenter
Use DotProduct maybe?
It returns the cosine angle of 2 vectors (whatever that means)

// Dot Product (a x b)
inline float vecDotProduct(vec3_t a , vec3_t b)
{
return ( a.x * b.x + a.y * b.y + a.z * b.z );
}


I think a and b must be normalized


make sure a and b are normalized otherwise it won t work
http://www.8ung.at/basiror/theironcross.html

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.