Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <map>
- #include <queue>
- #include <iomanip>
- #include <cassert>
- #include <cmath>
- #include <deque>
- using namespace std;
- #define pb push_back
- #define re return
- #define int long double
- struct pt
- {
- int x, y;
- int len()
- {
- return sqrt(x * x + y * y);
- }
- };
- pt vec(pt a, pt b)
- {
- return { b.x - a.x, b.y - a.y };
- }
- signed main()
- {
- ios_base::sync_with_stdio(false);
- pt a, b, c;
- cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;
- int A1 = b.y - a.y, B1 = -1 * (b.x - a.x), C1 = a.y * (b.x - a.x) - a.x * (b.y - a.y);
- int A2 = c.y - a.y, B2 = -1 * (c.x - a.x), C2 = a.y * (c.x - a.x) - a.x * (c.y - a.y);
- int z = sqrt(A2 * A2 + B2 * B2), z2 = sqrt(A1 * A1 + B1 * B1);
- int A3 = A1 * z + A2 * z2, B3 = B1 * z + B2 * z2, C3 = C1 * z + C2 * z2;
- if ((A3 * b.x + B3 * b.y + C3 > 0 && A3 * c.x + B3 * c.y + C3 < 0) || (A3 * b.x + B3 * b.y + C3 < 0 && A3 * c.x + B3 * c.y + C3 > 0))
- {
- cout << A3 << " " << B3 << " " << C3 << endl;
- }
- else
- {
- cout << A1 * z - A2 * z2 << " " << B1 * z - B2 * z2 << " " << C1 * z - C2 * z2 << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement