datsexyanon

So basically how bad did I fuck up?

May 6th, 2014
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include "zcommon.acs"
  2.  
  3. function int q_acos(int x, int y, int p)
  4. {
  5.     int baseangle = (3.141592653/2);
  6.     int r = sqrt( pow(x, 2) + pow(y, 2) );
  7.     int neg = 0;
  8.     int big = 0;
  9.    
  10.     //Check if angle is over 180
  11.     if (y < 0)
  12.     {
  13.         neg = 1;
  14.     }
  15.    
  16.     //check if angle is over 90
  17.     if (cos(baseangle) > (x/r))
  18.     {
  19.         big = 1;
  20.         x = -x;
  21.     }
  22.    
  23.     for (int i = 1; i <= p; i++)
  24.     {
  25.         if (cos(baseangle) > (FixedDiv(x,r)))
  26.         {
  27.             baseangle += (baseangle/(1+i));
  28.         }else if (cos(baseangle) < (FixedDiv(x,r))){
  29.             baseangle -= (baseangle/(1+i));
  30.         }else{
  31.             i = p;
  32.         }
  33.     }
  34.    
  35.     //if angle was over 90, fix
  36.     if (big == 1)
  37.     {
  38.         baseangle = 3.141592653 - baseangle;
  39.     }
  40.    
  41.     //if angle was over 180, fix
  42.     if (neg == 0)
  43.     {
  44.         return baseangle;
  45.     }else{
  46.         return 3.141592653 + (3.141592653 - baseangle);
  47.     }
  48. }
  49.  
  50. function int pow(int x, int y)
  51. {
  52.     int n = 1.0;
  53.     while (y-- > 0) { n = FixedMul(n, x); }
  54.     return n;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment