Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- struct Point {
- double x, y;
- Point(double x0 = 0, double y0 = 0)
- {
- x = x0;
- y = y0;
- }
- };
- istream & operator >> (istream & in, Point & P) {
- in >> P.x >> P.y;
- return in;
- }
- struct Vector {
- double x, y;
- Vector(double x0, double y0) {
- x = x0;
- y = y0;
- }
- Vector(Point A, Point B) {
- x = B.x - A.x;
- y = B.y - A.y;
- }
- };
- double scalarMulripl(Vector a, Vector b) {
- return a.x * b.x + a.y * b.y;
- }
- double vectMultipl(Vector a, Vector b) {
- return a.x * b.y - b.x * a.y;
- }
- int main() {
- Point O, A, B;
- double r;
- cin >> O >> r >> A >> B;
- cout << fixed << setprecision(10);
- if (r == 0) {
- cout << 0;
- return 0;
- }
- Vector OA = Vector(O, A);
- Vector OB = Vector(O, B);
- double sinAlpha = vectMultipl(OA, OB) / (r * r);
- double cosAlpha = scalarMulripl(OA, OB) / (r * r);
- double alpha = atan2(sinAlpha, cosAlpha);
- cout << abs(r * alpha);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement