Skip to content

Commit

Permalink
vectoyawpitch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lsalzman committed Feb 14, 2015
1 parent 32db47a commit 29b59d4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/shared/geom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ void vecfromyawpitch(float yaw, float pitch, int move, int strafe, vec &m)

void vectoyawpitch(const vec &v, float &yaw, float &pitch)
{
yaw = -atan2(v.x, v.y)/RAD;
pitch = asin(v.z/v.magnitude())/RAD;
if(v.iszero()) yaw = pitch = 0;
else
{
yaw = -atan2(v.x, v.y)/RAD;
pitch = asin(v.z/v.magnitude())/RAD;
}
}

static inline float det2x2(float a, float b, float c, float d) { return a*d - b*c; }
Expand Down

0 comments on commit 29b59d4

Please sign in to comment.