polar coordinates vector equation of a rectangle

Solution 1:

Let $(\pm a,\pm b)$ be the vertices of the rectangle.

When $x=a$, $r\cos \theta=a$

When $y=b$, $r\sin \theta=b$

Hence, $$r(\theta)= \left \{ \begin{array}{ccc} \displaystyle \frac{a}{|\cos \theta \,|} & , & \displaystyle |\tan \theta \,| \leq \frac{b}{a} \\ \displaystyle \frac{b}{|\sin \theta \,|} & , & \displaystyle |\tan \theta \,| \geq \frac{b}{a} \\ \end{array} \right.$$