I've been taking a intro to C++ class at school and was given the following practice problem:
Write a program that asks the user to input the x and y coordinates of two points, P and Q, in the plane. The program should calculate the coordinates for the point R which satisfies the following:
1) the line through QR is perpendicular to the line through PQ
2) the length of the line segment QR is equal to the length of PQ
The program should calculate and display the length of each side of the triangle formed by the points P, Q, R
I'm having issues finding and implementing the correct formula and subsequent code to determine point R for all cases. There are more requirements of the problem, but I can't get past this.
Straightforward solution:
1) Find offset O by substracting respective coordinates of P and Q (O = P - Q)
2) Convert O coords to the polar system
3) Add Pi/2 to the polar angle. (get O1)
4) Convert back to the cartesian
5) Add resulting offset to Q. (R = Q + O1)