Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include<math.h>
  3. using namespace std;
  4. #define pi 3.14
  5. struct POINTFLOAT
  6. {
  7. float x,y;
  8.  
  9. };
  10. int GetAngleABC( POINTFLOAT a, POINTFLOAT b, POINTFLOAT c )
  11. {
  12. POINTFLOAT ab = { b.x - a.x, b.y - a.y };
  13. POINTFLOAT cb = { b.x - c.x, b.y - c.y };
  14.  
  15. float dot = (ab.x * cb.x + ab.y * cb.y); // dot product
  16. float cross = (ab.x * cb.y - ab.y * cb.x); // cross product
  17. int val = (b.y - a.y) * (c.x - b.x) -
  18. (b.x - a.x) * (c.y - b.y);
  19.  
  20. if (val == 0) return 0; // colinear
  21.  
  22. float alpha = atan2(cross, dot);
  23.  
  24. if( (int) floor(alpha * 180. / pi + 0.5)==90){return val;}
  25. else return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement