As the figure above shows, we are given the following 4 points in the XY plane, listed in counter-clockwise direction:
We want to fit a square of general orientation to these four points. The only thing known about the points is that each point lies on a different side. They are ordered counter-clockwise to correspond with the sides.
Find the center and the side length of the fitting square, submit as your answer the concatenation of and and . For example, if the center is and the side length is , then your answer should be .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Following the solution of Mark Hennings for the original problem posted by Steven Chase, we define the direction vectors of the sides of the square as
u = ( cos θ , sin θ ) and v = ( − sin θ , cos θ )
It then follows by projecting the vector ( P 4 − P 2 ) onto u and ( P 1 − P 3 ) onto v , both projections being equal to the side length a , namely,
( P 4 − P 2 ) ⋅ u = ( P 1 − P 3 ) ⋅ v = a
which results in θ = 0 . 6 2 3 (radians). Next, we can find the side length from the above equation also by plugging in the value of θ found. The value thus found is a = 1 3 . 9 0 .
What is left to find the center, and for that we can write two equations in the two unknown coordinates of the center r C , namely,
( P 1 − r C ) ⋅ v = 2 1 a
and
( P 2 − r C ) ⋅ u = − 2 1 a
Solving this linear system gives r C = ( 4 . 1 3 , 5 . 4 6 )
Therefore, the answer is 4 1 3 5 4 6 1 3 9 0
Below is the fitted square.