All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Square from four points (Posted on 2013-01-08)

Given four points A, B, C, and D.

Construct a square PQRS such that the points A, B, C, and D lie on lines
PQ, QR, RS, and SP respectively
or
describe the configuration of the four points where the construction is not possible.

Note: Don't confuse lines (of infinite extent) with sides (of finite extent).

 See The Solution Submitted by Bractals Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Analytic beginning. | Comment 4 of 5 |
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

http://en.wikipedia.org/wiki/Parallel_%28geometry%29
gives a nice formula for the distance between parallel lines through two points.

The lines through A and C have distance
|(yc-ya)-m(xc-xa)|/√(m^2+1)
The lines through B and D have distance
|(yd-yb)-(-1/m)(xd-xb)|/√((-1/m)^2+1)

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.

Edit:
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))
or
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

 Search: Search body:
Forums (0)