$$z(X) = \frac{2\sin(\pi/n)}{g + 2h + w} \int_0^X \exp\!\left( i \sum_{r=0}^{n-1} \left[ \tfrac{\pi}{2}\sigma(x{-}t_1) - \tfrac{\pi}{2}\sigma(x{-}t_2) - \tfrac{\pi}{2}\sigma(x{-}t_3) + \tfrac{\pi}{2}\sigma(x{-}t_4) + \tfrac{2\pi}{n}\sigma(x{-}t_5) \right] \right) dx$$
↑ Four sigmoid turns per tooth ($+90°, -90°, -90°, +90°$) net to zero rotation. A fifth turn fires the polygon's $\tfrac{2\pi}{n}$ corner after the second half of the gap, centering each tooth on its edge.