Advertisement
C0BRA

Untitled

Oct 7th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. CAngle CVector::ToAngle() const // Thanks Spacetech
  2. {
  3.     double yaw, pitch;
  4.  
  5.     if(this->Y == 0 && this->X == 0)
  6.     {
  7.         yaw = 0;
  8.         pitch = this->Z > 0 ? 270 : 90;
  9.     }
  10.     else
  11.     {
  12.         yaw = (atan2(this->Y, this->X) * 180.0 / 3.14159263538979323);
  13.         if(yaw < 0)
  14.             yaw += 360;
  15.  
  16.         pitch = (atan2(-this->Z, this->Length2D()) * 180.0 / 3.14159265358979323);
  17.         if(pitch < 0)
  18.             pitch += 360;
  19.     }
  20.  
  21.     return CAngle(pitch, yaw, 0);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement