Advertisement
C0BRA

Untitled

Dec 1st, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. CAngle CVector::ToAngle() const
  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. }
  23.  
  24.  
  25.  
  26. CVector CVector::Normal()  const
  27. {
  28.     double Len = Length();
  29.     if(Len == 0)
  30.         Len = 1.0;
  31.     return CVector(X / Len, Y / Len, Z / Len);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement