Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. const long double PI = 3.14159265;
  8.  
  9. struct Vec {
  10. long double x, y;
  11.  
  12. Vec norm() const {
  13. return { x / len(), y / len() };
  14. }
  15.  
  16. Vec operator+ (const Vec &rhs) const {
  17. return {x + rhs.x, y + rhs.y};
  18. }
  19.  
  20. Vec operator- (const Vec &rhs) const {
  21. return { x - rhs.x, y - rhs.y };
  22. }
  23.  
  24. long double operator% (const Vec & rhs) const {
  25. return x * rhs.x + y * rhs.y;
  26. }
  27.  
  28. long double operator^ (const Vec & rhs) const {
  29. return x * rhs.y - rhs.x * y;
  30. }
  31.  
  32. template <typename T>
  33. Vec operator*(T rhs) const {
  34. return { x * rhs, y * rhs };
  35. }
  36.  
  37. template <typename T>
  38. Vec operator/(T rhs) const {
  39. return { x / rhs, y / rhs };
  40. }
  41.  
  42. long long len2() const {
  43. return 1LL * x * x + 1LL * y * y;
  44. }
  45.  
  46. long double len() const {
  47. return sqrt(x * x + y * y);
  48. }
  49. };
  50.  
  51. long double get_angle(Vec v1, Vec v2) {
  52. return atan2(v1 ^ v2, v1 % v2);
  53. }
  54.  
  55. int main() {
  56. //freopen("goat1.in", "r", stdin);
  57. //freopen("goat1.out", "w", stdout);
  58.  
  59. Vec p1, p2, p3, p4;
  60. cin >> p1.x >> p1.y;
  61. cin >> p2.x >> p2.y;
  62. cin >> p3.x >> p3.y;
  63. cin >> p4.x >> p4.y;
  64.  
  65. p1 = p1 - p2;
  66. p3 = p3 - p2;
  67. p4 = p4 - p2;
  68.  
  69. long double x1 = (p4 ^ p1), x2 = (p4 ^ p3);
  70. if (abs((p1 % p4) / abs(p1 % p4) - (p3 % p4) / abs(p3 % p4)) < 0.00000001) {
  71. cout << "YES";
  72. }
  73. else {
  74. cout << "NO";
  75. }
  76.  
  77.  
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement