# Parametric form of square

What is the appropriate parametric equation of the boundary of a square? For example, the unit circle has a parametric equation $x(t)=\cos(t)$ and $y(t)=\sin(t)$.

• $$[0,2\pi) \ni t\;\;\mapsto\;\; (x(t),y(t)) = \!\left(\frac{\cos(t)}{\rho(t)},\frac{\sin(t)}{\rho(t)}\right) \quad\text{ where }\quad \rho(t) = \max\big(|\cos(t)|,| \sin(t)|\big)$$ – achille hui Oct 17 '14 at 17:09
• The above is a parametric equation of circle not a square. Thank you. – Janak Oct 18 '14 at 7:28

Lets consider a square of size $2 \times 2$ in a rectangular coordinate system, where each side is a part of the lines $x = \pm 1, y = \pm 1$. Then you can define

$$\gamma(\alpha) = \begin{cases} (1,\tan(\alpha)) & \alpha \in [-\pi/4 , \pi/4] \\ (\cot(\alpha),1) & \alpha \in [\pi / 4, 3 \pi /4 ] \\ (-1,-\tan(\alpha)) & \alpha \in [3\pi/4 , 5\pi/4] \\ (-\cot(\alpha),-1) & \alpha \in [5\pi/4, 7\pi/4] \end{cases}$$

which describes the parametric path of square shape, with the angle as parameter.

A parametrization of a straight line from $$P$$ to $$Q$$ is $$r(t)=tP + (1-t)Q$$ as $$t$$ goes from $$0$$ to $$1$$. Four of these pieces with suitable start and stop values for $$t$$ will take you round the square for $$t$$ going from $$0$$ to $$4$$.

$$f(\alpha) = \sec(\alpha- \frac \pi2 \lfloor \frac {4\alpha + \pi}{2\pi}\rfloor )$$ Where $f$ is the function that gives the distance between the center of the square and a point of the square at the $\alpha$ angle

Giving us $$\begin{cases} \cos(\alpha) f(\alpha) \frac X2 +x_0\\ sin(\alpha) f(\alpha) \frac Y2 + y_0\\ \end{cases}$$

where X and Y the length and height respectivly and $x_0$ and $y_0$ are the coordonated of the square.