CGL_1_B Reflection
Table of contents
# Problem
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B&lang=ja
# Explanation
# Solution
void reflection(Vector2 start_, Vector2 end_, Vector2 p) {
Vector2 v = end_ - start_;
Vector2 b = start_ + v * (v.dot(p - start_) / v.norm());
Vector2 op = p + ((b - p) * 2);
cout << op.x << ' ' << op.y << endl;
}
#define MAX_N 1001
Int N;
Vector2 start_, end_, p;
void input() {
cin >> start_ >> end_ >> N;
while (cin >> p) {
reflection(start_, end_, p);
}
}
int main() {
cout.precision(15);
input();
}
Shun
Remote freelancer. A web and mobile application enginner.
Traveling around the world based on East Asia.
I'm looking forward to your job offers from all over the world!