fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define double long double
  4.  
  5. const double eps = 1e-10;
  6. const double inf = 1e18;
  7.  
  8. struct point {
  9. double Ox, Oy;
  10. point() {}
  11. point(double x, double y) : Ox(x), Oy(y) {}
  12. friend istream& operator >> (istream& in, point& o) {
  13. in >> o.Ox >> o.Oy;
  14. return in;
  15. }
  16. friend ostream& operator << (ostream& out, const point& o) {
  17. out << o.Ox << ' ' << o.Oy;
  18. return out;
  19. }
  20. friend point operator + (const point& A, const point& B) {return point(A.Ox + B.Ox, A.Oy + B.Oy);}
  21. friend point operator - (const point& A, const point& B) {return point(A.Ox - B.Ox, A.Oy - B.Oy);}
  22. friend point operator * (const point& A, const double& x) {return point(A.Ox * x, A.Oy * x);}
  23. friend point operator / (const point& A, const double& x) {return point(A.Ox / x, A.Oy / x);}
  24. double cross(const point& B) const {return Ox * B.Oy - Oy * B.Ox;}
  25. double cross(const point& B, const point& C) const {return (B - *this).cross(C - *this);}
  26. double dot(const point& B) {return Ox * B.Ox + Oy * B.Oy;}
  27.  
  28. double angle() const {return atan2l(Oy, Ox);}
  29. point perp() const {return point(Oy, -Ox);} // rotate 90 ccw
  30. double length() const {return sqrtl(Ox * Ox + Oy * Oy);}
  31. double dist(const point& A) const {return (A - *this).length();}
  32. };
  33.  
  34. bool acute(const point& A, const point& B, const point& C) { // checks angle ABC
  35. return (A - B).dot(C - B) > -eps;
  36. }
  37.  
  38. double angle(const point& A, const point& B, const point& C) {
  39. return acosl(min(1.0L, (A - B).dot(C - B) / ((A - B).length() * (C - B).length())));
  40. }
  41.  
  42. struct line {
  43. double a, b, c; // ax + by + c = 0
  44. line() {}
  45. line(const point& A, const point& B) {
  46. a = A.Oy - B.Oy; b = B.Ox - A.Ox;
  47. c = -(a * A.Ox + b * A.Oy);
  48. }
  49. friend istream& operator >> (istream& in, line& d) {
  50. in >> d.a >> d.b >> d.c;
  51. return in;
  52. }
  53. friend ostream& operator << (ostream& out, const line& d) {
  54. out << d.a << ' ' << d.b << ' ' << d.c;
  55. return out;
  56. }
  57.  
  58. double dist(const point& A) const {return abs(a * A.Ox + b * A.Oy + c) / sqrtl(a * a + b * b);}
  59. point eval(double x) const {return point(x, (-c - a * x) / b);}
  60. point intersect(const line& d) const {
  61. if (abs(a * d.b - b * d.a) < eps) return point(inf, inf);
  62. return point(b * d.c - d.b * c, -a * d.c + d.a * c) / (a * d.b - d.a * b);
  63. }
  64. };
  65.  
  66. signed main() {
  67.  
  68. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty