Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <iomanip>
- #include <fstream>
- #include <map>
- using namespace std;
- struct Point
- {
- double x;
- double y;
- };
- struct Vector
- {
- Point b;
- Point e;
- };
- inline double Cross(Vector p, Point T)
- {
- return (p.e.x - p.b.x)*(T.y - p.b.y) - (p.e.y - p.b.y)*(T.x - p.b.x);
- }
- int main()
- {
- ofstream fout("output.txt");
- ifstream fin("input.txt");
- int N, M;
- fin >> N >> M;
- vector<Point> points(N);
- vector<Vector> vectors(M);
- for(int i = 0; i < N; ++i) fin >> points[i].x >> points[i].y;
- for(int i = 0; i < M; ++i) fin >> vectors[i].b.x >> vectors[i].b.y >> vectors[i].e.x >> vectors[i].e.y;
- for(int i = 0; i < M; ++i)
- {
- double A = vectors[i].e.y - vectors[i].b.y;
- double B = -(vectors[i].e.x - vectors[i].b.x);
- double C = vectors[i].b.y*(-B) - vectors[i].b.x*A;
- for(int j = 0; j < N; ++j)
- {
- if(Cross(vectors[i], points[j]) <= 0)
- {
- Point N;
- double A2 = B;
- double B2 = -A;
- double C2 = A*points[j].y - B*points[j].x;
- double My = (-A*C2+A2*C)/(B2*A-B*A2);
- double Mx = -(C+B*My)/A;
- N.x = 2*Mx - points[j].x;
- N.y = 2*My - points[j].y;
- points[j] = N;
- }
- }
- }
- for(int i = 0; i < N; ++i) fout << fixed << setprecision(10) << points[i].x << " " << points[i].y << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement