# Construct a square given one side

I have two points $(x_1,y_1)$ and $(x_2,y_2)$

I want to calculate the other two points $(x_3,y_3)$ and $(x_4,y_4)$ of the square.

I have attached the image for explanation.

All 4 sides should be equal and have same angle.

-
Just for your information, about signing one's posts. – 1015 Apr 12 '13 at 5:52
there's more than one solution to this... you might simply construct a square on the given side... – long tom Apr 12 '13 at 5:55
Yes, its a square. Let me edit the post. – Ankit Sharma Apr 12 '13 at 5:56

1. $P_3 =(x_1+(y_2-y_1),y_1-(x_2-x_1))$, $P_4 =(x_2+(y_2-y_1),y_2-(x_2-x_1))$; and
2. $P_3'=(x_1-(y_2-y_1),y_1+(x_2-x_1))$, $P_4'=(x_2-(y_2-y_1),y_2+(x_2-x_1))$.
Thee two solutions are of course mirror images across the line extended through $x_1-x_2$. Performing the dot-product of $(P_2-P_1)$ with $(P_3-P_1)$ readily verifies that they two vectors form a $90$ degree angle. The remaining angles are quickly seen to also be $90$ degrees from inspection.