Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <array>
- #include <cassert>
- #include <climits>
- #include <cmath>
- #include <cstring>
- #include <iomanip>
- #include <iostream>
- #include <limits>
- #include <list>
- #include <map>
- #include <numeric>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <tuple>
- #include <unordered_map>
- #include <unordered_set>
- #include <vector>
- #define all(x) x.begin(), x.end()
- using namespace std;
- using ll = long long;
- using ld = long double;
- const double eps = 1e-10;
- const int mod = 1000000007;
- const ld PI = atan2l(0., -1.);
- struct Point { ld x; ld y; ld z; };
- struct Vector {
- ld x; ld y; ld z;
- ld Len() const { return sqrt(x * x + y * y + z * z); }
- ld Len2() const { return x * x + y * y + z * z; }
- };
- Point operator+(const Point& p, const Vector& v) { return {p.x + v.x, p.y + v.y, p.z + v.z}; }
- Point operator+(const Vector& v, const Point& p) { return {p.x + v.x, p.y + v.y, p.z + v.z}; }
- Point operator-(const Point& p, const Vector& v) { return {p.x - v.x, p.y - v.y, p.z - v.z}; }
- Vector operator-(const Point& p1, const Point& p2) { return {p1.x - p2.x, p1.y - p2.y, p1.z - p2.z}; }
- Vector operator+(const Vector& v1, const Vector& v2) { return {v1.x + v2.x, v1.y + v2.y, v1.z + v2.z};}
- Vector operator-(const Vector& v1, const Vector& v2) { return {v1.x - v2.x, v1.y - v2.y, v1.z - v2.z}; }
- ld DotProduct(const Vector& v1, const Vector& v2) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; }
- Vector CrossProduct(const Vector& v1, const Vector& v2) {
- 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};
- }
- istream& operator>>(istream& in, Point& v) { in >> v.x >> v.y >> v.z; return in; }
- istream& operator>>(istream& in, Vector& v) { in >> v.x >> v.y >> v.z; return in; }
- ostream& operator<<(ostream& out, const Point& v) { out << v.x << " " << v.y << " " << v.z; return out; }
- ostream& operator<<(ostream& out, const Vector& v) { out << v.x << " " << v.y << " " << v.z; return out; }
- void Solve() {
- Point p1, p2, p3; cin >> p1 >> p2 >> p3;
- Vector n = CrossProduct(p2 - p1, p3 - p2);
- cout << n << "\n";
- }
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- Solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment