What the problem boils down to is creating a pair of parallel lines through A and C with a second perpendicular pair through B and D. The four intersections of these lines would then be P,Q,R,S. The trick is to make this rectangle a square.
Let the lines through A and C have slope m
so the lines through B and D have slope -1/m
gives a nice formula for the distance between parallel lines through two points.
The lines through A and C have distance
The lines through B and D have distance
Setting these distances equal should allow us to solve for m. I don't have time to finish now but it looks quadratic in m which makes sense since playing with sketchpad indicates we often get two solutions.
It's not quadratic. The absolute values are giving the multiple solutions.
Setting the equations equal and simplifying a bit gives
|(yc-ya)-m(xc-xa)| = |(yd-yb)-(-1/m)(xd-xb)||m|
|(yc-ya)-m(xc-xa)| = |m(yd-yb)+(xd-xb)|
There will be two solutions: one for the possibility that the arguments inside the absolute values have the same sign and one for the possibility that the signs be different.
m = ((yc-ya)-(xd-xb))/((xc-xa)+(yd-yb))
m = ((yc-ya)+(xd-xb))/((xc-xa)-(yd-yb))
So the construction is complete.
Edited on January 10, 2013, 11:12 am
Posted by Jer
on 2013-01-09 13:48:50