Advertisement
Guest User

H

a guest
Feb 25th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. struct Point {
  8.     double x, y;
  9.  
  10.     Point(double x0 = 0, double y0 = 0)
  11.     {
  12.         x = x0;
  13.         y = y0;
  14.     }
  15. };
  16.  
  17. istream & operator >> (istream & in, Point & P) {
  18.     in >> P.x >> P.y;
  19.     return in;
  20. }
  21.  
  22.  
  23. struct Vector {
  24.     double x, y;
  25.  
  26.     Vector(double x0, double y0) {
  27.         x = x0;
  28.         y = y0;
  29.     }
  30.  
  31.     Vector(Point A, Point B) {
  32.         x = B.x - A.x;
  33.         y = B.y - A.y;
  34.     }
  35. };
  36.  
  37.  
  38. double scalarMulripl(Vector a, Vector b) {
  39.     return a.x * b.x + a.y * b.y;
  40. }
  41.  
  42.  
  43. double vectMultipl(Vector a, Vector b) {
  44.     return a.x * b.y - b.x * a.y;
  45. }
  46.  
  47.  
  48. int main() {
  49.     Point O, A, B;
  50.     double r;
  51.     cin >> O >> r >> A >> B;
  52.     cout << fixed << setprecision(10);
  53.     if (r == 0) {
  54.         cout << 0;
  55.         return 0;
  56.     }
  57.     Vector OA = Vector(O, A);
  58.     Vector OB = Vector(O, B);
  59.     double sinAlpha = vectMultipl(OA, OB) / (r * r);
  60.     double cosAlpha = scalarMulripl(OA, OB) / (r * r);
  61.     double alpha = atan2(sinAlpha, cosAlpha);
  62.     cout << abs(r * alpha);
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement