Stroke Width Transform: Gradient Direction Computation
If $Gx = 0$ and $Gy &gt; 0$, then we use $Gy / 0 = + \infty$. Note that $\arctan +\infty = 1$.

If $Gx = 0$ and $Gy &lt; 0$, then we use $Gy / 0 = -\infty$.  Note that $\arctan -\infty = -1$.