Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize ("O3")
- #include <bits/stdc++.h>
- #define pb push_back
- #define pf push_front
- #define all(a) (a).begin(), (a).end()
- #define heap priority_queue
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef pair<ll, ll> pll;
- const ll inf = numeric_limits<ll>::max() / 2;
- const ld eps = 1e-9;
- struct vect {
- ld x, y;
- vect() {}
- vect(ld x1, ld y1) {
- x = x1, y = y1;
- }
- vect operator + (vect a) {
- return vect(x + a.x, y + a.y);
- }
- vect operator - (vect a) {
- return vect(x - a.x, y - a.y);
- }
- ld operator * (vect a) {
- return x * a.x + y * a.y;
- }
- ld operator % (vect a) {
- return x * a.y - y * a.x;
- }
- vect operator * (ld k) {
- return vect(x*k, y*k);
- }
- vect rotate(ld a) {
- return vect(x*cos(a) - y * sin(a), x*sin(a) + y * cos(a));
- }
- };
- typedef tuple<ld, ld, ld> line;
- line equ(vect P, vect Q) {
- ld A = P.y - Q.y;
- ld B = Q.x - P.x;
- ld C = -A * P.x - B * P.y;
- return { A, B, C };
- }
- void solve(vect A, vect B, vect A1, vect B1) {
- vect P((A.x + A1.x) / 2, (A.y + A1.y) / 2);
- vect Q((B.x + B1.x) / 2, (B.y + B1.y) / 2);
- if ((P-Q)*(P-Q) < eps) {
- ld p, q, r;
- tie(p, q, r) = equ(A, B);
- Q = P + vect(p, q);
- }
- ld a, b, c;
- tie(a, b, c) = equ(P, Q);
- vect norm;
- if (a * A.x + b * A.y + c > 0) {
- norm = vect(-a, -b);
- } else {
- norm = vect(a, b);
- }
- ld L = abs(a*A.x + b * A.y + c) / sqrt(a * a + b * b);
- vect A2 = A + norm * (2 * L / sqrt(norm*norm));
- vect A2A1 = A1 - A2;
- cout << P.x << " " << P.y << endl;
- cout << Q.x << " " << Q.y << endl;
- cout << A2A1.x << " " << A2A1.y << endl;
- }
- int main() {
- ios_base::sync_with_stdio(0); cin.tie(0);
- ld x1, y1, x2, y2, x1_, y1_, x2_, y2_;
- cin >> x1 >> y1 >> x2 >> y2 >> x1_ >> y1_ >> x2_ >> y2_;
- cout << fixed;
- solve({ x1, y1 }, { x2, y2 }, { x1_, y1_ }, { x2_, y2_ });
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement