# Draw a square around a point.

I have a point on the graph at position X,Y , and I have to draw a square around that point of side X m. I have described my problem in the image.

I have taken an example square of 3 m. The diagonal of this square is 4.24 m(approx). I need to find the coordinates of the sides of the square.

-
You also need to specify the orientation of the square. – joriki Dec 12 '12 at 7:35
@joriki Orientation? Do you mean 2D,3D? If so, it's a 2D square. – Abijeet Patro Dec 12 '12 at 8:33
A square is always two-dimensional. I presume you're referring to the dimensionality of the space. I was a assuming that you're working in the plane and was referring to the angular orientation of the square within the plane. Clearly the coordinates of the slanted square that you drew differ from the coordinates of an axis-parallel square that ashley provided, and depend on the angular orientation. – joriki Dec 12 '12 at 9:04
If I understand this correctly then, the square will not be slanted at all, I'm sorry that the image does not depict that correctly. – Abijeet Patro Dec 12 '12 at 18:44

## 1 Answer

If your point is $(x,y)$ and side length is $k$, the coordinates of the square of which the sides are parallel to the x- and y-axes are $(x+n, y+n)$, $(x+n, y-n)$, $(x-n, y+n)$, $(x-n, y-n)$ where $n=k*sqrt(2)/2$. If you want angles by the axes, rotate.

-
This looks like it'll do the trick, I'll check and get back :) – Abijeet Patro Dec 12 '12 at 18:44