Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. const long double inf = 2e18;
  9.  
  10. struct point {
  11. long double x, y;
  12.  
  13. long double len() {
  14. return sqrt(x * x + y * y);
  15. }
  16.  
  17. void build(long double a, long double b) {
  18. x = a;
  19. y = b;
  20. }
  21. };
  22.  
  23. struct line {
  24. long double a, b, c, k, m;
  25.  
  26. long double getY(long double x) {
  27. if (b == 0) {
  28. return inf;
  29. }
  30.  
  31. return -(c + a * x) / b;
  32. }
  33.  
  34. long double getX(long double y) {
  35. if (a == 0) {
  36. return inf;
  37. }
  38.  
  39. return -(c + b * y) / a;
  40. }
  41.  
  42. void buildPoints(point x, point y) {
  43. a = x.y - y.y;
  44. b = y.x - x.x;
  45. c = x.x * y.y - y.x * x.y;
  46.  
  47. if (b == 0) {
  48. m = inf + x.x;
  49. k = inf;
  50. } else {
  51. m = -c / b;
  52. k = -a / b;
  53. }
  54. }
  55.  
  56. void build(long double A, long double B, long double C) {
  57. a = A;
  58. b = B;
  59. c = C;
  60.  
  61. if (b == 0) {
  62. m = inf;
  63. k = inf;
  64. } else {
  65. m = -c / b;
  66. k = -a / b;
  67. }
  68. }
  69. };
  70.  
  71. long double operator*(point a, point b) {
  72. return a.x * b.x + a.y * b.y;
  73. }
  74.  
  75. long double operator^(point a, point b) {
  76. return a.x * b.y - a.y * b.x;
  77. }
  78.  
  79. point operator-(point a, point b) {
  80. point res;
  81.  
  82. res.x = a.x - b.x;
  83. res.y = a.y - b.y;
  84.  
  85. return res;
  86. }
  87.  
  88. point operator+(point a, point b) {
  89. point res;
  90.  
  91. res.x = a.x + b.x;
  92. res.y = a.y + b.y;
  93.  
  94. return res;
  95. }
  96.  
  97. point operator*(long double k, point a) {
  98. point res;
  99. res.build(a.x * k, a.y * k);
  100. return res;
  101. }
  102.  
  103. long double distance(line l, point p) {
  104. return abs(l.a * p.x + l.b * p.y + l.c) / sqrt(l.a * l.a + l.b * l.b);
  105. }
  106.  
  107. int main() {
  108.  
  109. line ans;
  110. point x, y, z, p;
  111. long double a, b, ratio;
  112.  
  113. scanf("%Lf %Lf %Lf %Lf %Lf %Lf", &x.x, &x.y, &y.x, &y.y, &z.x, &z.y);
  114.  
  115. a = (x - y).len();
  116. b = (x - z).len();
  117.  
  118. ratio = a / b;
  119.  
  120. p = (1 / (ratio + 1)) * (y - z) + z;
  121.  
  122. // printf("%Lf %Lf\n", p.x, p.y);
  123.  
  124. ans.buildPoints(x, p);
  125.  
  126. printf("%Lf %Lf %Lf", ans.a, ans.b, ans.c);
  127.  
  128. return 0;
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement