y=\cases{0,&$0\leq x\hbox{mod}(a+2r)\leq a$\cr\cr (-1)^{x\hbox{div}(a+2r)}\sqrt{r^2-[x\hbox{mod}(a+2r)-a-r]^2},&$a