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)$.
 A: 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.

For using it in a program following works also very well: Define $\varphi(x) = \max(0, \min(1, 3/2 - \vert x \vert))$. Then
$\gamma: [0, 4] \to \mathbb R^2$ with $t \mapsto (\varphi(t-3/2), \varphi(t-5/2))$
works very well and doesn't need any expensive evaluations of trigonometric functions.
Note that $\gamma$ traces the boundary of $[0,1]^2$.
A: $$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.
A: 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$.
A: You can just break it down into 4 line segments:
$c(t)=(x(t),y(t))=$
$(t,0); 0\leq t\leq 1$
$(1, t-1); 1\leq t\leq 2$
$(3-t,1); 2\leq t\leq 3$
$( 0, 4-t); 3 \leq t\leq 4. $
A: Introduce a scaling factor r to the parameterization of the circle:
$x(t)=r(t)cos(t)$
$y(t)=r(t)sin(t)$
Then the following r gives a square with sidelenght 1
$r(t)=\frac{1}{\sqrt2 (|sin(t+\frac{\pi}{4})|+|cos(t+\frac{\pi}{4})|)}$
Or if you remove the phaseshift $\frac{\pi}{4}$ you get the scaling factor for a diamond.
$d(t)=\frac{1}{\sqrt2 (|sin(t)|+|cos(t)|)}$
