smatskevich

Seminar4

Feb 8th, 2025
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  1. #include <algorithm>
  2. #include <array>
  3. #include <cassert>
  4. #include <climits>
  5. #include <cmath>
  6. #include <cstring>
  7. #include <iomanip>
  8. #include <iostream>
  9. #include <limits>
  10. #include <list>
  11. #include <map>
  12. #include <numeric>
  13. #include <queue>
  14. #include <set>
  15. #include <sstream>
  16. #include <stack>
  17. #include <string>
  18. #include <tuple>
  19. #include <unordered_map>
  20. #include <unordered_set>
  21. #include <vector>
  22.  
  23. #define all(x) x.begin(), x.end()
  24. using namespace std;
  25. using ll = long long;
  26. using ld = long double;
  27. const double eps = 1e-10;
  28. const int mod = 1000000007;
  29.  
  30. const ld PI = atan2l(0., -1.);
  31.  
  32. struct Point { ld x; ld y; ld z; };
  33. struct Vector {
  34.   ld x; ld y; ld z;
  35.   ld Len() const { return sqrt(x * x + y * y + z * z); }
  36.   ld Len2() const { return x * x + y * y + z * z; }
  37. };
  38.  
  39. Point operator+(const Point& p, const Vector& v) { return {p.x + v.x, p.y + v.y, p.z + v.z}; }
  40. Point operator+(const Vector& v, const Point& p) { return {p.x + v.x, p.y + v.y, p.z + v.z}; }
  41. Point operator-(const Point& p, const Vector& v) { return {p.x - v.x, p.y - v.y, p.z - v.z}; }
  42. Vector operator-(const Point& p1, const Point& p2) { return {p1.x - p2.x, p1.y - p2.y, p1.z - p2.z}; }
  43. Vector operator+(const Vector& v1, const Vector& v2) { return {v1.x + v2.x, v1.y + v2.y, v1.z + v2.z};}
  44. Vector operator-(const Vector& v1, const Vector& v2) { return {v1.x - v2.x, v1.y - v2.y, v1.z - v2.z}; }
  45. ld DotProduct(const Vector& v1, const Vector& v2) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; }
  46. Vector CrossProduct(const Vector& v1, const Vector& v2) {
  47.   return {v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x};
  48. }
  49. istream& operator>>(istream& in, Point& v) { in >> v.x >> v.y >> v.z; return in; }
  50. istream& operator>>(istream& in, Vector& v) { in >> v.x >> v.y >> v.z; return in; }
  51. ostream& operator<<(ostream& out, const Point& v) { out << v.x << " " << v.y << " " << v.z; return out; }
  52. ostream& operator<<(ostream& out, const Vector& v) { out << v.x << " " << v.y << " " << v.z; return out; }
  53.  
  54. void Solve() {
  55.   Point p1, p2, p3; cin >> p1 >> p2 >> p3;
  56.   Vector n = CrossProduct(p2 - p1, p3 - p2);
  57.   cout << n << "\n";
  58. }
  59. int main() {
  60.   ios::sync_with_stdio(false);
  61.   cin.tie(nullptr);
  62.   cout.tie(nullptr);
  63.  
  64.   Solve();
  65.   return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment