Given points A and B, I want to draw a square with vertices A and B.
[![enter image description here](https://i.stack.imgur.com/Ub1Zg.png)](https://i.stack.imgur.com/Ub1Zg.png)

Of course, there are two possible squares along with a segment AB.

First, I thought that it could be drawn by using "rotate around={90:(A)}". This works well for moving a point, but it is not good for drawing a tilted square.

Using a perpendicular line through B is another way. But, it requires the length of AB. So, it makes too complicated codes.

I think there is a simple method to draw a square with given vertices. Could you let me know?