Advertisement
ivnikkk

Untitled

Apr 21st, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.32 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #define debug(l) cerr<<#l<<' '<<l<<'\n';
  3. #include "bits/stdc++.h"
  4. using namespace std;
  5. #define all(a) a.begin(), a.end()
  6. typedef long long ll;
  7. typedef pair<ll, ll> pll;
  8. typedef long double ld;
  9.  
  10. #define Vec Point
  11.  
  12. const ld EPS = 1e-13;
  13.  
  14. int sign(ld x) {
  15.     if (x > EPS) return 1;
  16.     if (x < -EPS) return -1;
  17.     return 0;
  18. }
  19.  
  20. ld sq(ld x) {
  21.     return x * x;
  22. }
  23.  
  24. struct Point {
  25.     ld x, y;
  26.     Point() : x(0), y(0) {}
  27.     Point(ld _x, ld _y) : x(_x), y(_y) {}
  28.     Point operator-(const Point& other) const {
  29.         return Point(x - other.x, y - other.y);
  30.     }
  31.     Point operator+(const Point& other) const {
  32.         return Point(x + other.x, y + other.y);
  33.     }
  34.     Point operator*(const ld& other) const {
  35.         return Point(x * other, y * other);
  36.     }
  37.     // векторное произведение sin
  38.     ld operator^(const Point& other) const {
  39.         return x * other.y - y * other.x;
  40.     }
  41.     // скалярное произведение cos
  42.     ld operator*(const Point& other) const {
  43.         return x * other.x + y * other.y;
  44.     }
  45.     ld len2() const {
  46.         return sq(x) + sq(y);
  47.     }
  48.     ld len() const {
  49.         return sqrt(len2());
  50.     }
  51.     Point norm() const {
  52.         ld d = len();
  53.         return Point(x / d, y / d);
  54.     }
  55.     bool operator<(const Point& other) const {
  56.         if (sign(x - other.x) != 0) {
  57.             return x < other.x;
  58.         }
  59.         else if (sign(y - other.y) != 0) {
  60.             return y < other.y;
  61.         }
  62.         return false;
  63.     }
  64.     bool operator==(const Point& other) const {
  65.         return sign(x - other.x) == 0 && sign(y - other.y) == 0;
  66.     }
  67.     Point ort() {
  68.         return Point(-y, x);
  69.     }
  70.     void deb() const {
  71.         std::cerr << "(" << x << ", " << y << ")" << std::endl;
  72.     }
  73. };
  74. ostream& operator << (ostream& out, const Point& val) {
  75.     return out << val.x << ' ' << val.y;
  76. }
  77. istream& operator >> (istream& in, Point& val) {
  78.     return in >> val.x >> val.y;
  79. }
  80. //расстояние от точки до точки
  81. ld dist_points(Point& a, Point& b) {
  82.     return sqrtl(sq(a.x - b.x) + sq(a.y - b.y));
  83. }
  84.  
  85. // угол между двумя векторами в радианах
  86. ld get_angle(const Vec& a, const Vec& b) {
  87.     return atan2(a ^ b, a * b);
  88. }
  89.  
  90. struct Line {
  91.     ld a, b, c;
  92.     Line() : a(0), b(0), c(0) {}
  93.     Line(const Point& x, const Point& y) : a(y.y - x.y), b(x.x - y.x), c(x.y* y.x - y.y * x.x) {
  94.         //// нормирование прямой
  95.         /*ld d = Point(a, b).len();
  96.         a /= d, b /= d, c /= d;
  97.         if (sign(a) == -1) {
  98.             a = -a;
  99.             b = -b;
  100.             c = -c;
  101.         }
  102.         else if (sign(a) == 0 && sign(b) == 0) {
  103.             a = 0;
  104.             b = -b;
  105.             c = -b;
  106.         }*/
  107.     }/*
  108.     Line norm() {
  109.         ld d =
  110.     }*/
  111.     //ax+by+c=0
  112.     ////y=-c/b
  113.     //Line norm() {
  114.     // 
  115.     //}
  116.     Point get() {
  117.         if (sign(b) != 0) {
  118.             return Point(0, -c / b);
  119.         }
  120.         else
  121.             return Point(0, -c);
  122.     }
  123.  
  124.     bool operator==(const Line& other) const {
  125.         return sign(a - other.a) == 0 && sign(b - other.b) == 0 && sign(c - other.c) == 0;
  126.     }
  127. };
  128. signed main() {
  129. #ifdef _DEBUG
  130.     freopen("input.txt", "r", stdin);
  131.     freopen("output.txt", "w", stdout);
  132. #endif
  133.     ios_base::sync_with_stdio(false);
  134.     cin.tie(nullptr);
  135.     cout.tie(nullptr);
  136.     srand(time(NULL));
  137.     Point x, y, z;
  138.     cin >> x >> y >> z;
  139.     Vec xy(y - x), xz(z - x);
  140.     xy = xy.norm(),xz = xz.norm();
  141.     Point x_(xy + xz);
  142.     //x_.x = x_.x / 2.0, x_.y = x_.y / 2.0;
  143.     Line ans(Point(x_+x), x);
  144.     cout << fixed << setprecision(6);
  145.     cout << ans.a << ' ' << ans.b << ' ' << ans.c;
  146.    
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement